[LLVMbugs] [Bug 8757] New: likely wrong code bug

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 7 21:27:38 PST 2010


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

           Summary: likely wrong code bug
           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 is right.

regehr at home:~$ clang -O1 small.c -o small
regehr at home:~$ ./small
g_62 = 255
regehr at home:~$ clang -O2 small.c -o small
regehr at home:~$ ./small
g_62 = 0
regehr at home:~$ clang -v

clang version 2.9 (trunk 121234)
Target: i386-pc-linux-gnu
Thread model: posix

regehr at home:~$ cat small.c

static int g_62 = 0;

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

static signed char foo(signed char left, int right)
{
   if ((left < 0) || (left > (127 >> right))) {
     return left;
   } else {
     return left << right;
   }
}

static unsigned short bar(unsigned short left, int right)
{
   return left >> right;
}

int main(void)
{
   int l_111[1];
   int i;
   for (i = 0; i < 1; i++)
       l_111[i] = 128;
   g_62 = bar(foo(l_111[0], 8), 8);
   printf("g_62 = %d\n", g_62);
   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