Clang segfaults when outputting endl
c++, clang, segmentation-fault
Solution
There's a bug pending for LLVM 3.4 regarding a similar issue. The problem seems an ABI incompatibility between LLVM 3.4 and MinGW 4.7+ that causes i686 instructions to be picked up instead of the selected target.
A possible solution on x64 Windows is to use a MinGW64 build. That should work but getting the standard library headers right could be tricky.
A recommended solution is to follow the steps here, adjust targets and any path on your system and get it to compile.
Problem
I am trying out Clang (version 3.4, via the Windows pre-built binaries) to see if it could be a suitable replacement for GCC (version 4.8.1, using MinGW); however, I am unable to get a simple program to work. ``` #include <iostream> int main() { std::cout << std::endl; } ``` Clang is able to compile and link the program, but running it results in a `SIGSEGV` signal and a return code of `0xC0000005`. Outputting a string works fine, but `std::flush` causes the same result, though allowing the stream to automatically flush itself is okay. Debugging the program just shows a call stack containing `__mingw_CRTStartup()` (Clang is using libstdc++, as it didn't install libc++) and `std::cout ()`. What might be causing this, and how could it be fixed? edit: The same thing happens when using other ostream manipulators such as `std::dec` and `std::unitbuf`.