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

2026-03-27


3129. Clarify which floating-point-literals are valid

Section: 5.13.4  [lex.fcon]     Status: ready     Submitter: Jan Schultke     Date: 2025-11-10

(From submission #801.)

Implementations diverge on whether the following declaration is well-formed:

  float x = 1e100000000000000000000000000000000000000000000000.f;

However, 5.13.4 [lex.fcon] paragraph 3 seems to be clear that this is allowed if float has a representation of infinity.

Proposed resolution (approved by CWG 2026-03-27):

Change in 5.13.4 [lex.fcon] paragraph 3 as follows:

If the scaled value is not in the range of representable values for its type, the program is ill-formed. Otherwise, the value of a floating-point-literal is the scaled value if representable, else the larger or smaller representable value nearest the scaled value, chosen in an implementation-defined manner.
[ Example:

The following example assumes that std::float32_t is supported (6.9.3 [basic.extended.fp]).

  std::float32_t x = 0.0f32;          // value 0 is exactly representable
  std::float32_t y = 0.1f32;          // rounded to one of two values nearest to 0.1
  std::float32_t z = 1e1000000000f32; // either greatest finite value or positive infinity
-- end example ]

Additional notes (March, 2026)

Assigned to SG6 at the request of the SG6 chair, via paper issue 2684.

The above resolution was approved by SG6 and EWG.