[llvm-bugs] [Bug 51775] New: -ffast-math breaks strtod() due to "== HUGE_VAL" considered impossible

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 7 02:15:54 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51775

            Bug ID: 51775
           Summary: -ffast-math breaks strtod() due to "== HUGE_VAL"
                    considered impossible
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: xavier.roche at algolia.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 25236
  --> https://bugs.llvm.org/attachment.cgi?id=25236&action=edit
Test aimed to reproduce the -ffast-math comparison bug

This is a regression from clang-11 to clang-12, but could be considered normal
if we consider -ffast-math as being "by design" unreliable w.r.t comparisons.

However, this breaks the use of functions such as strtod(), which can be
considered a more serious issue, because the "== HUGE_VAL" comparison is
considered by the compiler impossible and statically optimized as false

The attached program demonstrates the issue:

$ clang-11 -O1 -ffast-math
/tmp/ffast-math-strtod-overflow-condition-misoptimization-bug.c -o bug && ./bug
bad value

$ clang-12 -O1 -ffast-math
/tmp/ffast-math-strtod-overflow-condition-misoptimization-bug.c -o bug && ./bug
good value: inf

Clang versions 12 and above now are not seeing HUGE_VAL anymore

-- 
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/20210907/b994f1ec/attachment.html>


More information about the llvm-bugs mailing list