[cfe-dev] C2x FP_ROUND pragma meaning ambiguous?

Kevin Neal via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 5 12:30:48 PST 2021


I'm looking at #pragma STDC FP_ROUND in n2596. It isn't clear to me that the pragma is supposed to only apply to the compiler, or if the compiler is required to change the floating point environment when the compiled code is executed.

The draft says: "The FENV_ROUND pragma provides a means to specify a constant rounding direction for floating point operations for standard floating types within a translation unit or compound statement."

Use of the word "constant" sounds to me like it only applies to constants. Especially since the next paragraph contrasts the "constant rounding mode" with the "dynamic rounding mode". The "constant rounding mode" does not apply to functions that are called from a place where the #pragma is in effect.

On the other hand, paragraph 4 starts out with "The FENV_ROUND pragma affects operations for standard floating types. Within the scope of an FENV_ROUND pragma establishing a mode other than FE_DYNAMIC, floating-point operators, implicit conversions..."

That paragraph doesn't sound like the #pragma is restricted to operations on constants. Plus, there's a block of example code showing that the compiler "could" insert calls to fesetround().

So which is it? Is this pragma equivalent to a call to fesetround() or not?
--
Kevin P. Neal
SAS/C and SAS/C++ Compiler
Compute Services
SAS Institute, Inc.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210305/c12fbefb/attachment.html>


More information about the cfe-dev mailing list