http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60711
--- Comment #12 from Marc Glisse <glisse at gcc dot gnu.org> --- Before saying that there is a problem with libstdc++, did you try other implementations? clang++ with libc++ gives the same error. That's just not how streams are supposed to be used (pretend it is a pure virtual base class if that helps), please invest in a book.