This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Accepted as a DR at the June, 2024 meeting.]
Consider:
float f = {1e100};
This is rejected as narrowing on all implementations. Issue 2723 made the example non-narrowing, which seems incorrect on an IEEE platform.
Proposed resolution (approved by CWG 2024-04-19):
Change in 9.4.5 [dcl.init.list] paragraph 7 as follows:
A narrowing conversion is an implicit conversion
- from a floating-point type to an integer type, or
- from a floating-point type T to another floating-point type whose floating-point conversion rank is neither greater than nor equal to that of T, except where the
sourceresult of the conversion is a constant expression andthe actualeither its valueafter conversionis finite andwithin the range of values that can be represented (even if it cannot be represented exactly)the conversion did not overflow, or the values before and after the conversion are not finite, or- from an integer type ...
Additional notes (April, 2024)
According to the proposed wording, since NaNs are not finite, conversion of NaNs is always non-narrowing. However, the payload of the NaN might not be preserved when converting to a smaller floating-point type.