G
glen herrmannsfeldt
The subject recently came up in comp.compilers, though I believe that
I asked here before.
If you use relational operators, other than == and !=, on
pointers to different objects, is there any requirement on
the result?
#include <stdio.h>
int main() {
char *one="one";
char *two="two";
if(one<two || one>two) printf("not equal\n");
else printf("equal\n");
}
Is it allowed to print equal?
This question comes up for systems such as JVM that consider object
references as opaque, and the offset must be kept separately. For
operators other than == and != I would only compare the offset part.
JVM has only equality test for object references.
-- glen
I asked here before.
If you use relational operators, other than == and !=, on
pointers to different objects, is there any requirement on
the result?
#include <stdio.h>
int main() {
char *one="one";
char *two="two";
if(one<two || one>two) printf("not equal\n");
else printf("equal\n");
}
Is it allowed to print equal?
This question comes up for systems such as JVM that consider object
references as opaque, and the offset must be kept separately. For
operators other than == and != I would only compare the offset part.
JVM has only equality test for object references.
-- glen