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

            Bug ID: 19659
           Summary: wrong code at -O3 on x86_64-linux-gnu (affecting all
                    clang versions from 2.9 to trunk)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: s...@cs.ucdavis.edu
                CC: llvmbugs@cs.uiuc.edu
    Classification: Unclassified

The following code is miscompiled by the current clang trunk (and older
versions from 2.9) on x86_64-linux-gnu at -O3 in both 32-bit and 64-bit modes.

$ clang-trunk -v
clang version 3.5.0 (trunk 207963)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ 
$ clang-trunk -O2 small.c; a.out
1
$ clang-trunk -O3 small.c; a.out
0
$ clang-3.4 -O3 small.c; a.out
0
$ clang-3.3 -O3 small.c; a.out
0
$ clang-3.2 -O3 small.c; a.out
0
$ clang-3.1 -O3 small.c; a.out
0
$ clang-3.0 -O3 small.c; a.out
0
$ clang-2.9 -O3 small.c; a.out
0
$ 


-----------------------------------


int printf (const char *, ...);

int a, b, c, d;

void
foo (int p)
{
  if (p)
    b = 0;
}

int
main ()
{
  for (a = 0; a < 2; a++)
    {
      foo (a - (unsigned int) (b = 1) >= (unsigned int)a);
      if (c > 0)
    d = 0;
    }
  printf ("%d\n", b);
  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
LLVMbugs@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to