[Cfp-interest 2804] Re: FP_CONTRACT pragma and <math.h>

Vincent Lefevre vincent at vinc17.net
Thu Jul 20 09:13:40 PDT 2023


On 2023-07-04 15:08:17 -0700, Jim Thomas wrote:
> On Jul 4, 2023, at 6:55 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> > On 2023-07-03 09:16:23 -0700, Jim Thomas wrote:
> >> 1. C99 pragmas
> >> 
> >> FP_CONTRACT
> >> FENV_ACCESS
> >> CX_LIMITED_RANGE
> >> 
> >> are established. The prefixes reflect what the pragmas control. The
> >> association of FP_CONTRACT with math.h is questionable, since the
> >> pragma is about expression evaluation, not math functions.
> > 
> > There are other things in <math.h> that also apply just to
> > expressions, e.g. the float_t and double_t types (as said later),
> > and the INFINITY and NAN macros.
> > 
> > It seems that <float.h> is designed to be rather minimal for
> > freestanding implementations, for which <math.h> is optional.
> > But this means that there is no portable way to disable the
> > contraction of floating expressions for such implementations.
> > Is there anything to do about that?
> 
> Clause 4 #7 allows use of FP_CONTRACT on freestanding
> implementations that support Annex F.

However, when this pragma was introduced (and even still in C17),
this was not the case. This is new in C2x.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Cfp-interest mailing list