powr
(negative, qNaN)Authors: Joseph Myers
Date: 2025-03-18
Submitted against: C23
Status: Open
Annex F is unclear about whether powr
(x, qNaN) raises "invalid" for
negative x, though the intent seems to be that it should (as
indicated in reflector message
29708 and CFP message
3415).
C23 F.10.1 (Mathematics <math.h>
and <tgmath.h>
) says:
Functions with a NaN argument return a NaN result and raise no floating-point exception, except where explicitly stated otherwise.
C23 F.10.5.7 (The powr
functions) says:
powr
(x, y) returns a NaN and raises the "invalid" floating-point exception for x < 0.
This doesn't explicitly include the case where y is a NaN. By
contrast, F.10.5.8 (The rootn
functions) says:
rootn
(x, 0) returns a NaN and raises the "invalid" floating-point exception for all x (including NaN).
IEEE 754-2019 says in clause 9:
powr(x, y) signals the invalid operation exception for x < 0
and:
powr(x, qNaN) is qNaN for x ≥ 0
together with a more general statement:
Outside its domain an operation shall return a quiet NaN and signal the invalid operation exception.
This seems to indicate that "invalid" should be raised in this case.
In F.10.5.7 (The powr
functions), amend the seventh bullet point as
indicated.
powr
(x, y) returns a NaN and raises the "invalid" floating-point exception for x < 0 and all y (including NaN).
Comment from Issues list maintainer on 2025-06-27:
N3560 from the CFP group proposes the same wording as suggested in this issue.