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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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@imp r104]$ clang -w -O0 small.c ; ./a.out 
ffffffff
[regehr@imp r104]$ clang -w -O small.c ; ./a.out 
ff
[regehr@imp r104]$ gcc -w -O small.c ; ./a.out 
ffffffff
[regehr@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@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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to