This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: the standard rules for assigning types to integer constants inC


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]