[LLVMbugs] [Bug 8585] New: clang wrong at -O0?

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 10 15:39:51 PST 2010


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

           Summary: clang wrong at -O0?
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            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


A strange case.  We think the code is OK.  Uncharacteristically, it looks like
the -O0 result is wrong.

[regehr at n10 ~]$ clang -v
clang version 2.9 (trunk 118711)
Target: i386-pc-linux-gnu
Thread model: posix
[regehr at n10 ~]$ clang -O0 foo.c -o foo
[regehr at n10 ~]$ ./foo
g_5.f0 = 0
[regehr at n10 ~]$ clang -O1 foo.c -o foo
[regehr at n10 ~]$ ./foo
g_5.f0 = 1
[regehr at n10 ~]$ cat foo.c
struct S3 {
  int f0;
  unsigned f2 : 16;
};

struct S3 g_5 = {0,40000};

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

void  func_1(void)
{
   int *l_9 = &g_5.f0;
   int g_2 = 0;
     for (g_2 = 0; g_2 < -1; g_2++)
   {
   }
   *l_9 = g_5.f2 >= 0;
   printf("g_5.f0 = %d\n", g_5.f0);
}

int main(int argc, char* argv[])
{
   func_1();
   return 0;
}

-- 
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