[LLVMbugs] [Bug 12189] New: possible wrong code bug

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 5 10:53:40 PST 2012


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

             Bug #: 12189
           Summary: possible wrong code bug
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: regehr at cs.utah.edu
                CC: chenyang at cs.utah.edu, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


[regehr at gamow 1]$ clang -v
clang version 3.1 (trunk 151989)
Target: x86_64-unknown-linux-gnu
Thread model: posix
[regehr at gamow 1]$ clang -O1 small.c  ; ./a.out 
0
[regehr at gamow 1]$ clang -O2 small.c  ; ./a.out 
1
[regehr at gamow 1]$ cat small.c
int printf (const char *, ...);

short a;
int b, d, k, l, m;

int fn1 (short p1, int p2) {
  return p1 - p2;
}

int fn2 (short p1) {
  return p1 == 0 || a == 0 ? a : a % p1;
}

int fn3 (int p1, unsigned short p2) {
  return p2 == 0 ? 0 : p1 % p2;
}

void fn4 (unsigned char p1) {
  if (p1)
    b = 1;
}

void fn5 (p1) {
  short n = 60018;
  k = fn2 (p1);
  d = k != 0;
  l = fn1 (d, n);
  m = fn3 (l, p1);
  fn4 (m);
}

int main () {
  fn5 (2);
  printf ("%d\n", b);
  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