[LLVMbugs] [Bug 18673] New: -ftrapping-math flag ignored in optimization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 30 08:07:52 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18673

            Bug ID: 18673
           Summary: -ftrapping-math flag ignored in optimization
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: p.vanhoof at oma.be
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11978
  --> http://llvm.org/bugs/attachment.cgi?id=11978&action=edit
the test case

I recently installed the clang 3.4 release (from source, downloaded from the
llvm download page) on my 64-bit openSUSE 13.1 system. When I compiled the code
I develop, I noticed that it crashed almost immediately on an FP exception. The
same code ran fine under clang 3.3. I could reduce the problem to the attached
program.

If you compile this program with

% clang++ -O2 -ftrapping-math bug.cc
% ./a.out 
0
Floating exception

Compiling at a lower level gives the correct result:

% clang++ -O1 -ftrapping-math bug.cc
% ./a.out
0
1e+300

You need to supply the input value 0 on the command line to prevent the
compiler from pre-computing the result at compile time.

By inspecting the assembly, it appears that the compiler implements the
division more or less as

1./max(x,1.e-300) -> min(1./x,1e300)

However, such an optimization is not allowed when -ftrapping-math is in effect
since it will spuriously crash the program when x is zero.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140130/6caeb4c4/attachment.html>


More information about the llvm-bugs mailing list