This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4638. std::abs(float) is underspecified

Section: 29.7.2 [c.math.abs] Status: New Submitter: Jan Schultke Opened: 2026-11-06 Last modified: 2026-11-07

Priority: Not Prioritized

View other active issues in [c.math.abs].

View all other issues in [c.math.abs].

View all issues with New status.

Discussion:

29.7.2 [c.math.abs] states that std::abs(floating-point-type x):

Returns: The absolute value of x.

What is the absolute value of NaN? What happens when passing signaling NaN? What about infinity? Does it produce positive zero when given negative zero? What about floating-point exceptions? When is it a constant expression? Nobody knows.

In practice, all major standard libraries forward to std::fabs.

Proposed resolution:

This wording is relative to N5054.

  1. Modify 29.7.2 [c.math.abs] as indicated:

    constexpr floating-point-type abs(floating-point-type x);
    

    -4- ReturnsEffects: The absolute value of x Equivalent to: return fabs(x);.

    See also: ISO/IEC 9899:2024, 7.12.8.3, 7.24.7.1