This is the mail archive of the
mailing list for the GCC project.
Re: the standard rules for assigning types to integer constants in C
On Wed, Aug 22, 2001 at 06:37:34PM +0100, Joseph S. Myers wrote:
> On Tue, 21 Aug 2001, Zack Weinberg wrote:
> > 1: Were these rules different in C89? If so, what were they?
> They were different in C89:
> The type of an integer constant is the first of the corresponding
> list in which its value can be represented. Unsuffixed decimal:
> int, long int, unsigned long int; unsuffixed octal or hexadecimal:
> int, unsigned int, long int, unsigned long int; suffixed by the
> letter u or U: unsigned int, unsigned long int; suffixed by the
> letter l or L: long int, unsigned long int; suffixed by both the
> letters u or U and l or L: unsigned long int.
Aha. Thanks, it makes sense now.
> > 2: What, if anything, should we do about this?
> Implement the rules conditional on flag_isoc99 (making sure that something
> appropriate and consistent with ISO 14882 is done for C++) and change
> "integer constant type rules" in c99status.html from "Missing" to "Done".
> Work out what -Wtraditional ought to do in C99 mode if the C99 type is the
> same as the traditional type but different from the C89 type. No-one
> answered my question <URL:http://gcc.gnu.org/ml/gcc/2000-09/msg00417.html>
> about this, so I left off implementing this feature.
I'm testing a patch now.
In C99 mode, I chose to compare the C99 type with the traditional
type, but issue a -Wtraditional warning if the C89 and C99 types
don't match. This somewhat widens the scope of -Wtraditional, but