scjones@sdrc.UUCP (Larry Jones) (02/03/89)
I just ran across a bug in the c compiler on 386/3.0e. If you compare an unsigned constant expression to a signed constant expression, the result of the comparison is computed at compile time using a SIGNED comparison rather than an UNSIGNED comparison. For example: ~(unsigned)0 < 1000 is evaluated as 1 when it should clearly be 0. If you stick in a variable so that the compiler has to generate code, the code gets the right answer. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC scjones@sdrc.UU.NET 2000 Eastman Dr. BIX: ltl Milford, OH 45150 AT&T: (513) 576-2070 "When all else fails, read the directions."
dave@pmafire.UUCP (Dave Remien) (02/04/89)
In article <524@sdrc.UUCP> scjones@sdrc.UUCP (Larry Jones) writes:
:>I just ran across a bug in the c compiler on 386/3.0e. If you
:>compare an unsigned constant expression to a signed constant
:>expression, the result of the comparison is computed at compile
:>time using a SIGNED comparison rather than an UNSIGNED comparison.
:>
:>For example:
:>
:> ~(unsigned)0 < 1000
:>
:>is evaluated as 1 when it should clearly be 0. If you stick in a
:>variable so that the compiler has to generate code, the code gets
:>the right answer.
It's there, all right, using the cc (AT&T portable C compiler also used in
Bell Tech's System V/386), but not in either the Greenhills nor GNU C
compilers. Seems like a good reason to go GNU, yes? Actually, the
Greenhills C is pretty good as well; I just don't really like reading
the advertising for every module that gets compiled.
:>
:>----
:>Larry Jones UUCP: uunet!sdrc!scjones
:>SDRC scjones@sdrc.UU.NET
:>2000 Eastman Dr. BIX: ltl
:>Milford, OH 45150 AT&T: (513) 576-2070
:>"When all else fails, read the directions."
--
Dave Remien - WINCO Computer Engineering Group (only somewhat confused, now)
Work - 208-526-3523 Home - 208-524-1906 UUCP Path: ...!bigtex!pmafire!dave
"How can you be in two places at once, when you're not anywhere at all..."