ULONG_MAX in glimits.h
Brad Lucier
lucier@math.purdue.edu
Mon Sep 14 20:23:00 GMT 1998
I got the following error in an expression involving ULONG_MAX with
Monday's version of the mainline egcs cvs sources:
c_intf.c: In function `abs_bignum_to_ulong':
c_intf.c:479: warning: integer overflow in expression
c_intf.c:479: warning: comparison is always 1 due to limited range of data type
The value in gcc/glimits.h is defined as
#undef ULONG_MAX
#define ULONG_MAX (LONG_MAX * 2UL + 1)
This is copied to limits.h. When I redefined this to be
#undef ULONG_MAX
#define ULONG_MAX (((unsigned long) LONG_MAX) * 2UL + 1UL)
the problem went away. Wouldn't it just be better to define it as
#define ULONG_MAX (~(0UL))
Brad Lucier lucier@math.purdue.edu
More information about the Gcc-bugs
mailing list