This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ULONG_MAX in glimits.h


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]