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]

the standard rules for assigning types to integer constants in C



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

It goes on to describe the rules for U, L, UL, LL, and ULL suffixes, but
(if I'm reading this pile of spaghetti right) we only get the no-suffix
case wrong.

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?

[I'm not sure what "widest_integer_literal_type_node" corresponds
to in the user-visible language, and I bloody well hope we are not
inventing types longer than long long.  The standard talks about
"extended integer types", but the principle above holds: unsuffixed
decimal constants get only signed types.]

My question is twofold:

1: Were these rules different in C89?  If so, what were they?

2: What, if anything, should we do about this?

zw


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