[LLVMbugs] [Bug 17623] New: possible wrong code with volatile and lto

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Oct 19 07:58:19 PDT 2013


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: unassignedbugs at nondot.org
          Reporter: octoploid at yandex.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

Two examples:

1)
markus at 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 at x4 clang_bugs % clang -O0 -flto test_lto_crash.i && ./a.out
markus at x4 clang_bugs % clang -O2 -flto test_lto_crash.i && ./a.out
[1]    29647 segmentation fault  ./a.out
markus at x4 clang_bugs % clang -O2 test_lto_crash.i && ./a.out
markus at x4 clang_bugs % gcc -O2 -flto test_lto_crash.i && ./a.out
markus at x4 clang_bugs %

2)
markus at 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 at x4 clang_bugs % clang -w -O2 test_lto_wrong.i && ./a.out
5
markus at x4 clang_bugs % clang -w -O0 -flto test_lto_wrong.i && ./a.out
5
markus at x4 clang_bugs % gcc -w -O2 -flto test_lto_wrong.i && ./a.out
5
markus at x4 clang_bugs % clang -w -O2 -flto test_lto_wrong.i && ./a.out
4
markus at x4 clang_bugs %

-- 
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/20131019/08e58f70/attachment.html>


More information about the llvm-bugs mailing list