Interesting Bug in Microsoft C

Stan Brown browns at iccgcc.decnet.ab.com
Thu Mar 7 00:42:30 AEST 1991


In article <17307 at crdgw1.crd.ge.com>, volpe at camelback.crd.ge.com (Christopher R Volpe) writes:
> The compiler is correct. Using the constant "-2147483648L" is a bug
> if "2147483648" is too big to fit in a long. C doesn't have negative
> constants. It has positive constants preceded by the unary minus operator.
> Thus, "-2147483648L" is not a constant, but an integral constant expression
> containing a subexpression out of range. The correct way to code for this
> value is, as you already noted, "-2147483647L-1".                  

Would LONG_MIN (defined in <limits.h>) not be superior to these magic
numbers?  I know LONG_MIN is not necessarily -214783648, but it has
the virtue that it will compile.

My opinions are mine:  I don't speak for any other person or company.
                   email (until 91/4/30): browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA    +1 216 371 0043



More information about the Comp.lang.c mailing list