C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make C++ support C's standard pragmas

From: Jiang An <de34_at_[hidden]>
Date: Sun, 25 Sep 2022 23:03:36 +0800
I think a proper paper may need to contain two new pragmas in C23: STDC FENV_ROUND an STDC FENV_DEC_ROUND.

See also WG14 N3054.

Yours,
Jiang An

在 2022年9月25日 20:32,blacktea hamburger via Std-Proposals <std-proposals_at_[hidden]>写道:

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 and FENV_ACCESS can be added to C++ without much effort. CX_LIMITED_RANGE needs to be changed to apply to std::complex.

Are there other issues?

Received on 2022-09-25 15:03:53