draft ANSI standard: one change that would *really* help Europe

Guy Harris guy at sun.uucp
Sun Dec 14 18:06:03 AEST 1986


> I believe that the 3B2, to pick an example, places char in the high order
> byte of the register.

You may believe that, but it's not the case.  It's also completely
irrelevant; the C language states quite precisely what happens in the case
cited, both in the case where "char" is signed and in the case where "char"
is unsigned.  The implementation can put the character into any byte it
wants, as long as it behaves the way K&R, or the ANSI C spec, say it should.

> If you test one for equality with (int) -1 you will never pass the test.

That's because characters are UNsigned on the 3B2.

> As for the above construct working on any machine with signed char, I doubt
> that it will work on the 3B2.

See above.  The construct doesn't work on the 3B2 because it *isn't* a
machine with signed char.  The above construct *will* "work", in some sense,
on any C implementation with signed "char".  It *still* won't work
correctly; on a machine with signed "char" and 8-bit bytes, a byte with the
value 0xff will be sign-extended to -1, and thus will compare equal to EOF
even though it's a perfectly legitimate datum.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.lang.c mailing list