Bugs in OS9/68K C-Compiler ?
Doug Gwyn
gwyn at smoke.BRL.MIL
Fri Oct 28 10:31:33 AEST 1988
In article <636 at tuvie> rzmul3 at tuvie (Uni Leoben) writes:
>For the 'return 0 != ptr' problem : I don't know why, but 'return ptr != 0'
>works. Apparently the compiler automatically casts integers to pointers
>on comparisons but doesn't cast pointers to integers.
That certainly is a confused compiler. != is a symmetric operator.
It is not a matter of a cast (do YOU see a cast?) nor even of a type
conversion. Any pointer may be compared for (in)equality with a null
pointer, and 0 is one way to write a null pointer constant (in ANSI C,
(void*)0 is another). I think most programmers would find
return ptr != 0;
clearer than
return 0 != ptr;
but these are technically equivalent.
More information about the Comp.lang.c
mailing list