[LLVMbugs] [Bug 15940] New: Wrong constant folding

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 9 08:44:05 PDT 2013


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

            Bug ID: 15940
           Summary: Wrong constant folding
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: ishiura-compiler at ml.kwansei.ac.jp
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

LLVM (git) + clang (3.4) for x86_64 miscompiles the following code.

    $ cat error.c

    int x = 1;
    int main (void)
    {
      if ( 5 % ( 3 * x ) + 2 != 4 ) __builtin_abort();
      return 0;
    }

    $ clang error.c -O1
    $ ./a.out
    Aborted (core dumped)

The following code with variable x replaced by "1" is
correctly compiled.

    $ cat noerror.c

    int main (void)
    {
      if ( 5 % ( 3 * 1 ) + 2 != 4 ) __builtin_abort();
      return 0;
    }

    $ clang noerror.c -O1
    $ ./a.out
    0

    $ clang -v
    clang version 3.4 (http://llvm.org/git/clang.git
    3923d6a87fe7b2c91cc4a7dbd90c4ec7e2316bcd)
    (http://llvm.org/git/llvm.git
    363160a6be82df343fa60aa09d9d8f8f44605529)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix

-- 
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/20130509/53369860/attachment.html>


More information about the llvm-bugs mailing list