[cfe-dev] Constexpr evaluation and Inf/NaN

JVApen via cfe-dev cfe-dev at lists.llvm.org
Sun Jul 7 01:39:48 PDT 2019

Hello all,

I've recently been looking into constexpr evalution and the exceptional
values of floating point numbers.
After asking this on stackoverflow (
https://stackoverflow.com/a/56920473/2466431), I didn't get a clear answer
on if this is defined behavior or not, nor how this plays together with
Similarly, it's unclear why operations resulting in INF/NAN ain't allowed
at constexpr while the right thing happens by optimization. (Ignoring some
side effects where it sometimes still works)

Looking back at it today, the example at CompilerExplorer worked, which I
traced back to https://reviews.llvm.org/D63793 (by rsmith).
Our issue seems to be resolved for INF, though, not yet for NaN, as it has
a // FIXME: C++ rules require us to not conform to IEEE 754 here.

Can you elaborate on the plan to resolve the FIXME and if possible the
And in case this is very unclear, is there an option to have
-fconstexpr-iec559 flag that allows the calculation at constexpr?

Thanks in advance for the feedback
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190707/c087de8f/attachment.html>

More information about the cfe-dev mailing list