This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-05
The intended treatment of a floating point infinity with respect to narrowing conversions is not clear. Is std::numeric_limits<double>::infinity() usable in a constant expression, for example, and should that be different from a calculation that results in an infinity?
Notes from the October, 2015 meeting:
CWG requests the assistance of SG6 in resolving this issue.
Notes from the November, 2016 meeting:
SG6 said that arithmetic operations (not conversions) that produce infinity are not allowed in a constant expression. However, using std::numeric_limits<T>::infinity() is okay, but it can't be used as a subexpression. Conversions that produce infinity from non-infinity values are considered to be narrowing conversions.
Possible resolution (October, 2025):
Change in 6.9.2 [basic.fundamental] paragraph 13:
Theminimumrange of representable values for a floating-point type is the most negative finite floating-point number representable in that type through the most positive finite floating-point number representable in that type.In addition, if negative infinity is representable in a type, the range of that type is extended to all negative real numbers; likewise, if positive infinity is representable in a type, the range of that type is extended to all positive real numbers. [Note 10: Since negative and positive infinity are representable in ISO/IEC 60559 formats, all real numbers lie within the range of representable values of a floating-point type adhering to ISO/IEC 60559. —end note]
Change in 7.1 [expr.pre] paragraph 4 as follows:
An arithmetic expression is a unary plus or minus (7.6.2.2 [expr.unary.op]), binary plus or minus (7.6 [expr.compound]), or binary multiplication, division, or remainder (7.6.5 [expr.mul]) expression where every operand is of arithmetic type. Ifduring the evaluation of an expression,the result of evaluating an arithmetic expression is not mathematically defined or not in the range of representable values for its type, the behavior is undefined. [Note 3: Treatment of division by zero, forming a remainder using a zero divisor, and all floating-point exceptions varies among machines, and is sometimes adjustable by a library function. —end note][ Example:
constexpr std::float32_t inf = std::numeric_limits<std::float32_t>::infinity(); // OK, infinity not produced by arithmetic expression constexpr std::float32_t max = std::numeric_limits<std::float32_t>::max(); // OK constexpr std::float32_t min = std::numeric_limits<std::float32_t>::min(); // OK constexpr std::float32_t d0 = max / 0; // error: division by zero (7.6.5 [expr.mul]) constexpr std::float32_t inf2 = max + max; // error: infinity produced constexpr std::float32_t nan = inf - inf; // error: NaN produced constexpr std::float32_t zero = min / max; // OK, result is too small to be represented, but is within the range of representable values-- end example ]