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

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 3 15:58:20 PDT 2013


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

            Bug ID: 17473
           Summary: possible wrong code bug
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: regehr at cs.utah.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Well this one is weird since fn2 isn't even called, but it can't be removed or
the bad behavior goes away.

[regehr at imp r104]$ clang -w -O0 small.c ; ./a.out 
ffffffff
[regehr at imp r104]$ clang -w -O small.c ; ./a.out 
ff
[regehr at imp r104]$ gcc -w -O small.c ; ./a.out 
ffffffff
[regehr at imp r104]$ cat small.c
int printf(const char *, ...);
int a, c, d, e, f, g, i, j;
short b;
char h;

int fn1(void) 
{ 
  return b && a > b || b < 0 && a ?: b; 
}

void fn2(void) {
  for (;; f = fn1())
    ;
}

void fn3(int p1) {
  j &&(c = 0 ?: 0);
  g = p1;
}

int main(void) {
  for (h = 0; h >= 0; ++h) {
    fn3(h);
    i = d >= 0 ?: 0;
  }
  e = g;
  e += h;
  printf("%x\n", e);
  return 0;
}
[regehr at imp r104]$ clang -v
clang version 3.4 (trunk 191880)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131003/5f43032e/attachment.html>


More information about the llvm-bugs mailing list