This is the mail archive of the gcc-bugs@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: gcc compiler bug: unsigned enum types



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>

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