Bug with unsigned int data type?

Moore, Mathew L MooreML@BATTELLE.ORG
Sun Oct 13 08:18:00 GMT 2002


If there is no suffix on an integer constant, according to the C99 standard,
it must be converted to the first type on the list {int, long int, long long
int} in which its value can be represented.  So maybe the warning should say
something about the conversion from long long to unsigned?

The C89 standard, which gcc 2.95 probably follows a little more closely, had
the conversion list as {int, long int, unsigned long int}, so maybe then the
warning should go away.  But then again, it might be nice for the programmer
to know when that conversion is occuring.

gcc 3.2 still gives the warning you see.

You can get around that warning by using the suffix on the constant:

n = 2147483648u;

--Matt


> -----Original Message-----
> From: Steve Dondley [mailto:s@dondley.com]
> Sent: Sunday, October 13, 2002 10:29
> To: gcc-help@gcc.gnu.org
> Subject: Bug with unsigned int data type?
> 
> 
> Hi,
> 
> The following two lines...
> 
> unsigned int n;
> n = 2147483648;
> 
> ...generate a "decimal constant is so large thst it is 
> unsigned" warning.
> Shouldn't the declaration of the integer as unsigned avoid 
> this warning?
> I'm using gcc version 2.95.4 on an Intel 32 bit machine.
> 
> Thanks.
> 
> 



More information about the Gcc-help mailing list