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]
Other format: [Raw text]

[Bug c++/61568] unscoped enums different types differ from __underlying_type


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61568

--- Comment #2 from Melissa <myriachan at cox dot net> ---
(In reply to Harald van Dijk from comment #1)
> The C++ standard requires an unscoped enumeration type with an underlying
> type that is not fixed to promote to signed int, if signed int is capable of
> representing all the values in the enumeration's range. And the
> enumeration's range depends on the values of the enumeration constants, not
> on the enumeration's underlying type, so it requires this even if the
> underlying type is unsigned int. This may be confusing, but I think that
> what GCC implements is exactly what the standard requires, and that there is
> no bug in GCC here.

I think you're right about this, Harold, particularly because clang exhibits
the same behavior.  (Visual Studio 2012 and 2013 don't, but they use an
underlying type of "signed int"; this makes MSVS equally compliant under this
interpretation of the Standard but for a different reason.)

But I also think that the Standard is being a little silly here.  It seems
broken to me that an enum promotes differently than its underlying type does. 
Maybe that compilers are permitted to do this should be reported as a possible
erratum in the Standard.


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