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]
Other format: [Raw text]

Re: g++ unsigned warning

[Get raw message]
Benjamin Kosnik wrote:-

> on x86/linux with current:
> 
>   unsigned long ul1 = 4294967294;
> 
> unsigned.cc:1: warning: decimal constant is so large that it is unsigned
> 
> other platforms with:
> 
>   #include <limits>
>   unsigned long ul1 = std::numeric_limits<unsigned long>::max();
> 
> 
> ?? What's the deal? It already is unsigned.

Decimal integer constants are signed by default, unless they're "big".
That's the warning you're getting.  Maybe define your constant in hex.

Neil.


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