C++ Logo

std-proposals

Advanced search

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

From: blacktea hamburger <greenteahamburger_at_[hidden]>
Date: Sat, 1 Oct 2022 20:55:07 +0800
Thanks for reminding me.

I wonder if there is any previous proposal to add these pragmas to C++.

On Sun, Sep 25, 2022 at 11:03 PM Jiang An via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> 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 <https://wg14.link/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?
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-10-01 12:55:41