Bugs in OS9/68K C-Compiler ?
Bob Larson
blarson at skat.usc.edu
Fri Oct 28 15:23:27 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. I don't know what
>K&R says to this case. Perhaps someone with more C insight could comment
>on this.
The order of the comparison dosn't matter, 0 must be converted to the
approprate type.
char *ptr;
return 0 != ptr;
is equivelent to:
char *ptr;
return (char *)0 != ptr;
(I'm quite sure K&R, H&S, K&R-II, and the ANSI drafts all argee on this.)
[Microware is gradually converting from a K&R based compiler to an ANSI
one, when I talked to him a few years ago Kim Kempf (microware's C
compiler guru) was on the ANSI committee.]
--
Bob Larson Arpa: Blarson at Ecla.Usc.Edu blarson at skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list: info-prime-request%ais1 at ecla.usc.edu
oberon!ais1!info-prime-request
More information about the Comp.lang.c
mailing list