Title
Lossless narrowing conversions
Status
nad
Section
9.4.5 [dcl.init.list]
Submitter
Hubert Tong

Created on 2014-08-13.00:00:00 last changed 121 months ago

Messages

Date: 2014-11-15.00:00:00

Rationale (November, 2014):

CWG felt that type-based (in contrast to value-based) restrictions such as this should not depend on the platform-specific characteristics of the type, so the general rule should apply.

Date: 2022-11-20.07:54:16

According to 9.4.5 [dcl.init.list] bullet 7.3, an implicit conversion

from an integer type or unscoped enumeration type to a floating-point 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

is a narrowing conversion. There does not seem to be a good reason why a conversion from, for example, an unsigned char value to a floating point value should be considered to be narrowing, since floating point types should be able represent all the values.

History
Date User Action Args
2014-11-24 00:00:00adminsetmessages: + msg5286
2014-08-13 00:00:00admincreate