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

2024-12-06


377. Enum whose enumerators will not fit in any integral type

Section: 9.7.1  [dcl.enum]     Status: CD1     Submitter: Mark Mitchell     Date: 30 August 2002

[Voted into WP at April 2003 meeting.]

9.7.1 [dcl.enum] defines the underlying type of an enumeration as an integral type "that can represent all the enumerator values defined in the enumeration".

What does the standard say about this code:

  enum E { a = LONG_MIN, b = ULONG_MAX };

?

I think this should be ill-formed.

Proposed resolution:

In 9.7.1 [dcl.enum] paragraph 5 after

The underlying type of an enumeration is an integral type that can represent all the enumerator values defined in the enumeration.
insert
If no integral type can represent all the enumerator values, the enumeration is ill-formed.