What's a C expert?

Conor P. Cahill cpcahil at virtech.UUCP
Sun Aug 13 13:56:23 AEST 1989


In article <4722 at alvin.mcnc.org>, spl at mcnc.org (Steve Lamont) writes:
> 
> However, when I tried this on my IRIS 4D to confirm my theory, I got the
> "wrong" answer.  In other words, it did not print FALSE when run.  My
> assumption is that the C compiler is not propagating the sign when
> promoting x to an int in the if-statment.  (I don't read MIPS assembly
> code well enough to verify this)
> 

The problem may be that the char data type may be unsigned by default.  This
was true on the 3b2 when it first came out (I'm not sure if it is still true,
but on the original machines there was no way to make a signed character).
This wrecked havoc on an office automation product that was being ported 
to the system because lots of code expected 0xff in a character to equal -1 
in an integer.

The final answer is that the branch in that code is implementation dependent.
I'm not sure if this issue is addressed in the ANSI standard, but one would
hope that it was.



More information about the Comp.lang.c mailing list