On Fri, Mar 25, 2016 at 9:01 AM, <
b7.10...@gmail.com> wrote:
> n4567 defines <cfenv> contents in 26.3.1, saying that the header defines all
> functions, types, and macros the same as Clause 7.6 of the C standard. But
> in the C standard there's a follow-up clause 7.6.1, which describes the
> FENV_ACCESS pragma and says that if the program tests floating-point status
> flags, sets FP control modes or runs under non-default mode settings, but
> was translated with the state for the FENV_ACCESS pragma "off", the behavior
> is undefined.
> At the same time, FENV_ACCESS appears to be unmentioned in the C++ standard
> draft. Does this mean any of the following:
>
> a) According to the C++ standard, a program is to behave as if FENV_ACCESS
> state is always "on"
No, there is no such implication.
> b) FENV_ACCESS pragma is implicitly defined the same way as in the C
> standard
No.
> c) Using <cfenv> is broken and always leads to undefined behavior in C++
Pretty much. But if your implementation happens to support #pragma
STDC FENV_ACCESS in C++, then it would not be unreasonable to expect
it to work.
Note that C++ does not even define the underlying notions on which
<fenv.h> is based (C++'s specification for floating point types is
incredibly weak compared to C's). Also, the interaction of floating
point constant expression evaluation and FENV_ACCESS would need to be
specified in order for <cfenv> to be meaningful in C++.