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

2024-10-26


1601. Promotion of enumeration with fixed underlying type

Section: 7.3.7  [conv.prom]     Status: C++14     Submitter: Ville Voutilainen     Date: 2013-01-09

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

According to 7.3.7 [conv.prom] paragraph 4,

A prvalue of an unscoped enumeration type whose underlying type is fixed (9.7.1 [dcl.enum]) can be converted to a prvalue of its underlying type. Moreover, if integral promotion can be applied to its underlying type, a prvalue of an unscoped enumeration type whose underlying type is fixed can also be converted to a prvalue of the promoted underlying type.

Because both of these conversions have the same rank, a call like the following is ambiguous, even though conversion to the underlying type might seem better than conversion to int:

  enum E : char { e };
  void f(char);
  void f(int);
  void g() {
    f(e);      // ambiguous
  }

On the other hand, character types often have non-numeric semantics in programs, and programmers might use a character type just to set the size of the enumeration's object representation, not to imply character semantics for the enumeration. It might be better to leave the ambiguity in place in order to require programmers to make their intent explicit.

Proposed resolution (June, 2013):

Change 12.2.4.3 [over.ics.rank] paragraph 4 as follows:

...Two conversion sequences with the same rank are indistinguishable unless one of the following rules applies: