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]

Re: integer


> while playing around with type "int" I came across the following
> statement:
> 
>  int i=-2147483648;
> 
> When compiling I got the following message:
> 
> "warning: decimal integer constant is so large that it is unsigned"
> 
> I think this is a bug since the range of the values of type "int" 
> on a 32bit platform is [ -2^31, 2^31) which is -2147483648 to
> 2147483647.

Thanks for your bug report. This is not a bug. In C, -2147483648 is
not a constant, but an expression. 2147483648 is a constant; it is
denoted as signed, but does not fit into signed int, hence the
warning.

If you intended to use a constant for the smallest integer, please use
INT_MIN from <limits.h>; that will compile correctly.

Regards,
Martin

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