semantics of arith comparisons

Doug Gwyn gwyn at smoke.brl.mil
Thu Feb 7 06:48:06 AEST 1991


In article <1991Feb6.085315.10468 at sics.se> matsc at sics.se (Mats Carlsson) writes:
>This must be a compiler bug.  Surely the value of an expression shouldn't
>change by storing it in a variable *of the same type* as the expression
>has.

All bets are off when overflow occurs.  You were lucky you didn't get
an ABEND instead of merely strange numerical results.  For integer
arithmetic with reasonable overflow semantics, use an unsigned type.



More information about the Comp.lang.c mailing list