[LLVMbugs] [Bug 8547] New: likely x86 miscompile using clang

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 4 07:07:27 PDT 2010


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

           Summary: likely x86 miscompile using clang
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu, chenyang at cs.utah.edu


The -O1 result looks wrong.

regehr at home:~$ clang -O0 foo.c -o foo
regehr at home:~$ ./foo
g_2 = 64
regehr at home:~$ clang -O1 foo.c -o foo
regehr at home:~$ ./foo
g_2 = 320
regehr at home:~$ cat foo.c
int g_2;

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

int main(void) {
  for (g_2 = 0; g_2 > -1; g_2++)
    {
      g_2 = (char)(g_2 << 6);
      if (g_2)
    break;
      g_2 = 4;
    }
  printf("g_2 = %d\n", g_2);
  return 0;
} 
regehr at home:~$ clang -v
clang version 2.9 (trunk 118140)
Target: i386-pc-linux-gnu
Thread model: posix

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list