[cfe-dev] [llvm-dev] Should rint and nearbyint be always constrained?

Serge Pavlov via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 5 09:48:33 PST 2020


+cfe-dev as the discussion is now biased toward C standard.

I'm not sure what problem you see here.  In default mode, i.e.
> when there is no "#pragma STDC FENV_ACCESS on" in effect,
> then the compiler can always assume that the default rounding
> mode is in effect.


Well, if #pragma STDC FENV_ACCESS on is not in effect, that means
> that the user has promised that at this point during execution,
> we will *always* have the default FP environment.
>

This is a strong statement (no pragma == default mode), we need to confirm
it with proper references to the standard. If it is true and the code:

float qqq(float x) {
  return nearbyint(x);
}


is really equivalent to:


float qqq(float x) {
  return roundeven(x);
}


(in absence of 'pragma STD FENV_ACCESS), it is a fact that would be
surprise for many user.

Thanks,
--Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200306/49ead284/attachment.html>


More information about the cfe-dev mailing list