This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
ULONG_MAX in glimits.h
- To: egcs-bugs at cygnus dot com
- Subject: ULONG_MAX in glimits.h
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Mon, 14 Sep 1998 22:23:32 -0500 (EST)
- Cc: lucier at math dot purdue dot edu
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