[LLVMbugs] [Bug 16130] New: clang produces incorrect code with loop/expression at -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 23 14:38:34 PDT 2013


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

            Bug ID: 16130
           Summary: clang produces incorrect code with loop/expression at
                    -O2
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dhazeghi at yahoo.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following testcase produces incorrect results when compiled with current
clang trunk at -O2 or above on x86_64-linux-gnu.  clang 3.2 does not have this
behavior.

$ clang-trunk -v
clang version 3.4 (trunk 182568)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -Os wrong.c 
$ ./a.out 
8
$ clang-3.2 -O2 wrong.c 
$ ./a.out 
8
$ clang-trunk -O3 wrong.c 
$ ./a.out 
0
$
----------------------------
int printf (const char *, ...);
int a;
int
fn1 ()
{
    int b = 0;
    for (; b != 13; b =b+8)
            if ((a = b)) return 1;
    return 0;
}

int
main ()
{
    int c = fn1 ();
    printf ("%d\n", a);
    return 0;
}

-- 
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/20130523/df0d40e8/attachment.html>


More information about the llvm-bugs mailing list