This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61568] unscoped enums different types differ from __underlying_type
- From: "myriachan at cox dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Jun 2014 19:30:57 +0000
- Subject: [Bug c++/61568] unscoped enums different types differ from __underlying_type
- Auto-submitted: auto-generated
- References: <bug-61568-4 at http dot gcc dot gnu dot org/bugzilla/>
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.