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

            Bug ID: 17623
           Summary: possible wrong code with volatile and lto
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: lto
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Playing with csmith I came across several possible wrong code bugs with lto.

Two examples:

1)
markus@x4 clang_bugs % cat test_lto_crash.i
int a, b, e;
int *c;
int **volatile d = &c;
int main() {
  for (; a <= 0; a++) {
    e = 0;
    *d = &e;
    if (*c)
      return 0;
  }
  return 0;
}
markus@x4 clang_bugs % clang -O0 -flto test_lto_crash.i && ./a.out
markus@x4 clang_bugs % clang -O2 -flto test_lto_crash.i && ./a.out
[1]    29647 segmentation fault  ./a.out
markus@x4 clang_bugs % clang -O2 test_lto_crash.i && ./a.out
markus@x4 clang_bugs % gcc -O2 -flto test_lto_crash.i && ./a.out
markus@x4 clang_bugs %

2)
markus@x4 clang_bugs % cat test_lto_wrong.i
int a, b;
int *volatile c = &b;
int main() {
  a = 1;
  for (; a; a--) {
    *c = 1;
    b |= 4;
  }
  printf("%d\n", b);
  return 0;
}
markus@x4 clang_bugs % clang -w -O2 test_lto_wrong.i && ./a.out
5
markus@x4 clang_bugs % clang -w -O0 -flto test_lto_wrong.i && ./a.out
5
markus@x4 clang_bugs % gcc -w -O2 -flto test_lto_wrong.i && ./a.out
5
markus@x4 clang_bugs % clang -w -O2 -flto test_lto_wrong.i && ./a.out
4
markus@x4 clang_bugs %

-- 
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