public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Bug with unsigned int data type?
@ 2002-10-13  8:18 Moore, Mathew L
  0 siblings, 0 replies; 3+ messages in thread
From: Moore, Mathew L @ 2002-10-13  8:18 UTC (permalink / raw)
  To: 'Steve Dondley', gcc-help

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.
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug with unsigned int data type?
  2002-10-13  7:24 Steve Dondley
@ 2002-10-13  8:06 ` bjorn rohde jensen
  0 siblings, 0 replies; 3+ messages in thread
From: bjorn rohde jensen @ 2002-10-13  8:06 UTC (permalink / raw)
  To: Steve Dondley; +Cc: gcc-help

Hi Steve,

  Your litteral is signed as it is written, and the
nice gcc/g++ compiler is warning you. You need to
write the litteral as 2147483648U.

Yours sincerely,

Bjorn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Bug with unsigned int data type?
@ 2002-10-13  7:24 Steve Dondley
  2002-10-13  8:06 ` bjorn rohde jensen
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Dondley @ 2002-10-13  7:24 UTC (permalink / raw)
  To: gcc-help

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-13 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13  8:18 Bug with unsigned int data type? Moore, Mathew L
  -- strict thread matches above, loose matches on Subject: below --
2002-10-13  7:24 Steve Dondley
2002-10-13  8:06 ` bjorn rohde jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).