[Cfp-interest 1915] Domain errors for NaNs?

Jim Thomas jaswthomas at sbcglobal.net
Fri Feb 12 17:33:04 PST 2021


Should quiet and/or signaling NaNs be domain errors?

(This question was recently raised in off-group communication with a C++ committee member.)

C allows implementation-defined domain errors for NaN inputs, but they are not required domain errors.

Quiet NaNs do not signal exceptions in IEC 60559, because the best result (in most cases) is clear and because unhelpful signals would proliferate. The same arguments apply to regarding quiet NaN inputs as domain domain errors. Also, if quiet NaN inputs were required or implementation-defined domain errors, the implementation could not report these domain errors via floating-point exceptions without violating IEC 60559 and Annex F requirements.

Prior to the C23 draft, C essentially disregarded signaling NaNs and treated all NaNs as quiet. (Signaling NaNs must be explicitly created by the program, and any utility they have requires additional, non-portable semantics.) The floating-point specification in C23 is intended to allow the implementation to support signaling NaNs. In IEC 60559, signaling NaN inputs do raise exceptions (and yield quiet NaN results). C allows signaling NaN inputs to be implementation-defined domain errors, as they would be if the implementation supported signaling NaNs. However, C23 Annex F does not require support for signaling NaNs, and making signaling NaN inputs be required domain errors would a significant, incompatible change, for no apparent value.

- Jim Thomas




More information about the Cfp-interest mailing list