Title
Gratuitously-unsigned underlying enum type
Status
c++14
Section
9.7.1 [dcl.enum]
Submitter
Daniel Krügler

Created on 2013-02-03.00:00:00 last changed 122 months ago

Messages

Date: 2013-09-15.00:00:00

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

Date: 2013-08-15.00:00:00

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:

  • If an initializer is specified for an enumerator...

  • If no initializer is specified for the first enumerator, the initializing value has an unspecified signed integral type.

  • Otherwise...

Date: 2013-02-03.00:00:00

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.

History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: drwp -> c++14
2014-03-03 00:00:00adminsetstatus: dr -> drwp
2013-10-14 00:00:00adminsetmessages: + msg4686
2013-10-14 00:00:00adminsetstatus: tentatively ready -> dr
2013-09-03 00:00:00adminsetmessages: + msg4457
2013-09-03 00:00:00adminsetstatus: open -> tentatively ready
2013-02-03 00:00:00admincreate