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

            Bug ID: 16733
           Summary: Infinite loopo segfaults with optimisation level 1 and
                    above
           Product: clang
           Version: 3.1
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

If the following code is compiled with optimisation level 1, 2 or 3, it
segfaults. With optimsation level 0 it hangs forever as it is supposed to.

ex.cpp:
-------
#include<iostream>

void test() {
  for(std::size_t n = 1; n < 4 ;++n ) 
    n >>=1; 
}

int main() {
  test();
}

Bash:
-----
$ clang++ -O1 ex.cpp -o program
$ ./program
Segmentation fault: 11
$ clang++ --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix

Note that the function call is essential. This code:

#include<iostream>

int main() {
  for(std::size_t n = 1; n < 4 ;++n ) 
    n >>=1; 
}

works.

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