[LLVMbugs] [Bug 5132] New: apparent clang wrong code at -O0

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Oct 4 11:58:26 PDT 2009


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

           Summary: apparent clang wrong code at -O0
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu


I think 1 is the right answer.

regehr at john-home:~/volatile/tmp202$ clang small.c -o small
regehr at john-home:~/volatile/tmp202$ ./small
checksum = 0
regehr at john-home:~/volatile/tmp202$ clang small.c -o small -O
regehr at john-home:~/volatile/tmp202$ ./small
checksum = 1

regehr at john-home:~/volatile/tmp202$ clang -v

clang version 1.1 (http://llvm.org/svn/llvm-project/cfe/trunk 83272)
Target: i386-pc-linux-gnu
Thread model: posix

regehr at john-home:~/volatile/tmp202$ cat small.c

#include <stdint.h>
#include <stdio.h>

uint8_t g_14 = 250;
volatile uint64_t g_91;
uint8_t g_151;

int32_t func_16 (int8_t p_19, int64_t p_20);
int32_t func_16 (int8_t p_19, int64_t p_20)
{
  return p_20;
}

int32_t func_35 (int64_t p_38);
int32_t func_35 (int64_t p_38)
{
  if (func_16 (g_14, 1 <= g_14))
    for (g_91 = 1; 1; )
      return 1;
  return 1;
}

int main (void)
{
  func_35 (1);
  printf ("checksum = %lld\n", g_91);
  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