This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc compiler bug: unsigned enum types
- To: Alan Morgan <arm at thebe dot camcon dot co dot uk>
- Subject: Re: gcc compiler bug: unsigned enum types
- From: Geoff Keating <geoffk at cygnus dot com>
- Date: 11 Sep 2000 07:56:48 -0700
- CC: gcc-bugs at gcc dot gnu dot org
- References: <14780.46997.718579.917335@thebe.camcon.co.uk>
Alan Morgan <arm@thebe.camcon.co.uk> writes:
> The bug is that gcc makes "an enum type be of type unsigned int (or maybe
> unsigned char) rather than signed int as it should be according to K&R 2nd
> edition section A8.4 pages 214-215."
The ISO C standard, in section 6.7.2.2 "enumeration specifiers",
paragraph 4, says
Each enumerated type shall be compatible with *char*, a signed
integer type, or an unsigned integer type. The choice of type is
implementation-defined, but shall be capable of representing the
values of all the members of the declaration.
The previous 1989 version of the C standard simply said
Each enumerated type shall be compatible with an integer type;
the choice of type is implementation-defined.
which is equivalent, except that an implementation is free to choose a
type that is too small. GCC complies with the current version of the
standard in this respect. The K&R books are not necessarily complete
descriptions of the standard.
--
- Geoffrey Keating <geoffk@cygnus.com>