[llvm-dev] Possible bug in optimizer

Tim Northover via llvm-dev
Sun, 29 Apr 2018 18:44:20 -0000

Hi Andrea,

On 28 April 2018 at 15:32, Andrea Venturoli via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>    feenableexcept(FE_OVERFLOW); //**** NOTE 1

There are two problems here. One with the code and one with Clang.

First, in order to use these floating-point environment functions, the
C (and C++) language requires you to use "#pragma stdc fenv_access
on". Without that, the compiler is free to assume that exceptions
aren't possible and the default rounding mode prevails regardless of
the calls you make. And Clang does.

Unfortunately, the other half is the Clang bug: it doesn't actually
support that #pragma yet. It'll warn (yay!?) but won't actually make
your code work.

One final silver lining is that there's actually a reasonably active
effort to start supporting the pragma going on now. We've got most of
a plan, bits are implemented, and people are working on it. Now that
you know to search for the keyword "fenv_access" you should be able to
find lots more discussion on these lists. Though probably not a
committed timeline, I'm afraid.

Cheers.

Tim.