*BSD News Article 13970


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!metro!ipso!runxtsa!bde
From: bde@runx.oz.au (Bruce Evans)
Subject: Re: gcc 2.3.3 bug?
Message-ID: <1993Apr3.232448.28122@runx.oz.au>
Organization: RUNX Un*x Timeshare.  Sydney, Australia.
References: <1p7c3mINNdh5@urmel.informatik.rwth-aachen.de> <1993Mar30.092201.1099@runx.oz.au> <1993Apr3.032136.2935@njitgw.njit.edu>
Date: Sat, 3 Apr 93 23:24:48 GMT
Lines: 23

In article <1993Apr3.032136.2935@njitgw.njit.edu> kxn3796@hertz.njit.edu (Ken Nakata CIS stnt) writes:

>If the scanner evaluates "2147483648" at first and then it takes negative
>value with '-', I can understand.  It's likely that the warning is produced
>when the scanner evaluates an unsigned value 2147483648.  Is this correct?

All correct.

>But even if this is correct, it seems to me that this depends on the
>compiler's implementation.  I wonder whether or not there are more
>sophisticated explanations...

It's ANSI standard.  K&R2 p193 A2.5.1 says this about Integer Constants:
"If it is unsuffixed and decimal, it has the first if these types in
which its value can be represented: int, long int, unsigned long int".

Oops.  I said that the type of -2147483648 is unsigned, but it is
unsigned long.  The difference is not great when unsigned and long have
the same size.

Bruce
-- 
Bruce Evans  bde@runx.oz.au