Date: Sun, 25 Sep 2022 23:03:36 +0800
According to 6.10.6 of C N2176:
If the preprocessing token STDC does immediately follow pragma in the directive (prior to any macro replacement), then no macro replacement is performed on the directive, and the directive shall have one of the following forms178) whose meanings are described elsewhere:
- #pragma STDC FP_CONTRACT on-off-switch
- #pragma STDC FENV_ACCESS on-off-switch
- #pragma STDC CX_LIMITED_RANGE on-off-switch
FP_CONTRACT
(7.12.2):The FP_CONTRACT pragma can be used to allow (if the state is “on”) or disallow (if the state is “off”) the implementation to contract expressions (6.5).
FENV_ACCESS
(7.6.1):The FENV_ACCESS pragma provides a means to inform the implementation when a program might access the floating-point environment to test floating-point status flags or run under non-default floating-point control modes.
CX_LIMITED_RANGE
(7.3.4)The usual mathematical formulas for complex multiply, divide, and absolute value are problematic because of their treatment of infinities and because of undue overflow and underflow. The CX_LIMITED_RANGE pragma can be used to inform the implementation that (where the state is “on”) the usual mathematical formulas are acceptable.
FP_CONTRACT
andFENV_ACCESS
can be added to C++ without much effort.CX_LIMITED_RANGE
needs to be changed to apply tostd::complex
.Are there other issues?
Received on 2022-09-25 15:03:53