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

2023-02-07


1449. Narrowing conversion of negative value to unsigned type

Section: 9.4.5  [dcl.init.list]     Status: CD3     Submitter: Richard Smith     Date: 2012-01-28

[Moved to DR at the October, 2012 meeting.]

According to 9.4.5 [dcl.init.list] paragraph 7, an implicit conversion

from an integer type or unscoped enumeration type to an integer type that cannot represent all the values of the original type, except where the source is a constant expression and the actual value after conversion will fit into the target type and will produce the original value when converted back to the original type.

As is made plain in the examples in that paragraph, a conversion of a negative value to an unsigned type is intended to be a narrowing conversion; however, the phrase “actual value after conversion” makes this intent unclear, especially since the round-trip conversion between signed and unsigned types might well yield the original value.

Proposed resolution (February, 2012):

Change 9.4.5 [dcl.init.list] paragraph 7 as follows:

A narrowing conversion is an implicit conversion

[Note:...