[LLVMbugs] [Bug 17381] New: -fsanitize=undefined false positive on conditional operator and floating-point division by 0 with constants

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 26 06:24:17 PDT 2013


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

            Bug ID: 17381
           Summary: -fsanitize=undefined false positive on conditional
                    operator and floating-point division by 0 with
                    constants
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vincent-llvm at vinc17.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

ypig:~> clang --version
Debian clang version 3.4-1 (trunk) (based on LLVM 3.4)
Target: x86_64-pc-linux-gnu
Thread model: posix

ypig:~> cat tst.c
#include <stdio.h>

int main (void)
{
  volatile int i, t = 0;
  volatile double x;
  double z = 0.0;

  i = t ? 0 / 0 : 0;
  printf ("[1] %d\n", i);
  x = t ? z / z : z;
  printf ("[2] %g\n", x);
  x = t ? 0.0 / 0.0 : 0.0;
  printf ("[3] %g\n", x);
  return 0;
}

ypig:~> clang -fsanitize=undefined tst.c -o tst
tst.c:9:13: warning: division by zero is undefined [-Wdivision-by-zero]
  i = t ? 0 / 0 : 0;
            ^ ~
1 warning generated.

ypig:~> ./tst
[1] 0
[2] 0
tst.c:13:15: runtime error: division by zero
[3] 0

but because t == 0, the 0.0 / 0.0 in the third test should never be evaluated.
The first two tests are OK, so that it seems related to floating-point division
with constants specifically.

This bug yields a failure in the tget_flt test of the GNU MPFR trunk r8685
with:
  clang -O2 -fsanitize=undefined -fno-sanitize-recover

-- 
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/20130926/d65249dc/attachment.html>


More information about the llvm-bugs mailing list