This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61584] What defines std::underlying_type?
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Jun 2014 07:16:38 +0000
- Subject: [Bug c++/61584] What defines std::underlying_type?
- Auto-submitted: auto-generated
- References: <bug-61584-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61584
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Structures-unions-enumerations-and-bit-fields-implementation.html
The integer type compatible with each enumerated type (C90 6.5.2.2, C99 and C11
6.7.2.2).
Normally, the type is unsigned int if there are no negative values in the
enumeration, otherwise int. If -fshort-enums is specified, then if there are
negative values it is the first of signed char, short and int that can
represent all the values, otherwise it is the first of unsigned char, unsigned
short and unsigned int that can represent all the values.
On some targets, -fshort-enums is the default; this is determined by the ABI.
--- CUT ---
C++ semi-follows C here, though instead of being a compatible type, it is the
underlying type.