https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81751
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- The current __basic_file::sys_open behaviour came from the PR 17215 fix (r86756). Before that change we called sync() after doing _M_cfile=__file, but after we call sync() while it's still null. I think rather than changing sync(), the correct fix is to not call it while _M_cfile is null. Instead we should directly call fflush(__file) in sys_open. That should restore the behaviour that was present before GCC 3.4.4