integer

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Thu Mar 23 01:03:00 GMT 2000


> 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


More information about the Gcc-bugs mailing list