This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


1618. Gratuitously-unsigned underlying enum type

Section: 9.7.1  [dcl.enum]     Status: C++14     Submitter: Daniel Krügler     Date: 2013-02-03

[Moved to DR at the September, 2013 meeting.]

In an enumeration whose underlying type is not fixed, the type of the first enumerator is unspecified if it has no initializer, meaning that an implementation could choose either a signed or an unsigned type. As a result, the values of one and two in this example could be either -1 and 0 or very large unsigned numbers:

  enum { zero, one = zero -1, two };

It would be better if 9.7.1 [dcl.enum] paragraph 5 specified the type of the first enumerator as a signed type.

Proposed resolution (August, 2013):

Change 9.7.1 [dcl.enum] paragraph 5 as follows:

...If the underlying type is not fixed, the type of each enumerator is the type of its initializing value: