[llvm-bugs] [Bug 45352] New: Undefined Behavior sanitizer finding for 1.0f / 0.0f

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 29 15:40:09 PDT 2020


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

            Bug ID: 45352
           Summary: Undefined Behavior sanitizer finding for 1.0f / 0.0f
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: noloader at gmail.com
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

The following is producing an Undefined Behavior sanitizer finding:

    ASSERT(INFINITY == 1.0f / 0.0f);

After a quick read of IEEE 754, it looks like that is conforming behavior for
floats. According the IEEE 754, conforming behavior is infinity if a trap is
not raised.

    $ cat test.c
    #include <float.h>
    #include <math.h>
    int main(void)
    {
      return INFINITY == 1.0f / 0.0f ? 0 : 1;
    }

    $ clang -fsanitize=undefined test.c -o test.exe
    $ ./test.exe 
    test.c:5:27: runtime error: division by zero

GCC does not produce a finding for floats.

-- 
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/20200329/3d2f1894/attachment-0001.html>


More information about the llvm-bugs mailing list