the standard rules for assigning types to integer constants inC
Bernd Schmidt
bernds@redhat.com
Wed Aug 22 04:10:00 GMT 2001
On Tue, 21 Aug 2001, Zack Weinberg wrote:
>
> ... don't seem to match what has been implemented in GCC.
>
> C99 6.4.4.1, paragraph 5, describes how the type is to be chosen:
>
> The type of an integer constant is the first of the corresponding
> list in which its value can be represented.
>
> Suffix Decimal Constant Octal or Hex Constant
> ------ ---------------- ---------------------
> none int int
> unsigned int
> long long
> unsigned long
> long long long long
> unsigned long long
What if a decimal constant only fits into an unsigned long long?
> The table we're using for no suffix is:
>
> Decimal Octal or Hex
> ------- ------------
> int int
> unsigned int
> long long
> unsigned long unsigned long
> long long long long
> unsigned long long unsigned long long
> intmax_t? intmax_t?
>
> My question is twofold:
>
> 1: Were these rules different in C89? If so, what were they?
C89 didn't have long long. I believe I recall seeing a comment that explained
the problem - for better compatibility we didn't want to go to long long
automatically if a number didn't fit into a long. But I may misremember this.
> 2: What, if anything, should we do about this?
Make it dependent on which version of the standard the user has selected?
Bernd
More information about the Gcc
mailing list