The following code causes a segfault when it's compiled with clang and linked against libc++ but works fine when using libstc++ or compiling with gcc.
#include <iostream>
#include <sstream>
class MyStream : public std::ostream {
public:
    MyStream() {
        rdbuf( &buffer );
    }
private:
    std::stringbuf buffer;
};
int main() {
    MyStream stream{};
    stream << "Hello world" << std::endl;
    return 0;
}
 
    