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: "harald at gigawatt dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Jun 2014 17:14:45 +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
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> ---
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.
This may indeed be a duplicate of bug 58559, which seems to be invalid for the
same reason. In the comparison e < 0, e is promoted to signed int (except in C,
where it does promote to unsigned int). In the cast (long long) e, the
enumeration value (with an unsigned underlying type) is converted directly to
long long, without any intermediate promotion.