dimanche 25 janvier 2015

Tying a stream to itself

Why does this code run successfully on g++ and clang (libstdc++) but give a segmentation fault with libc++:



#include <iostream>

int main()
{
std::cout.tie(&std::cout);
std::cout << 123;
}


What I think should happen is that std::cout.flush() should be called before the output actually occurs. Why would this give a segmentation fault?


Aucun commentaire:

Enregistrer un commentaire