https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98108
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> --- Right, this actually has nothing to do with threads. The behaviour is exactly the same as if file1.cc contained this instead: void threadfunc(); struct StaticThread { StaticThread() { threadfunc(); } }; static StaticThread thread1; A global constructor calls threadfunc() before std::cout has been initialized. It doesn't matter whether that happens in a separate thread or not, and in either case the solution is to include <iostream> so that a std::ios_base::Init object is constructed before your global.