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: Possible C++ bug: Are C enum tags unsigned?


> But I vaguely recall a rule in ANSI C that enum values decay to int
> when you use them.  Is my memory being over-specific about the type?

[C says]
Each enumerated type shall be compatible with an integer type. The
choice of type is implementation-defined, but shall be capable of
representing the values of all the members of the enumeration.
[6.7.2.2/4]

GCC defines this implementation choice as

  /* Construct the final type of this enumeration.  It is the same
     as one of the integral types - the narrowest one that fits, except
     that normally we only go as narrow as int - and signed iff any of
     the values are negative.  */
[c-decl.c:finish_enum]

Regards,
Martin

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