https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81256
Bug ID: 81256 Summary: basic_filebuf::close doesn't propagate exceptions Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: programmerjake at gmail dot com Target Milestone: --- in line 247 of fstream.tcc, basic_filebuf::close ignores exceptions thrown by _M_terminate_output. _M_terminate_output calls unshift on the codecvt facet from the imbued locale. unshift might throw if using a custom codecvt facet. the standard (N4659) says (30.9.2.3.7), referring to calling unshift and other functions: If one of these calls throws an exception, the exception is caught and rethrown after closing the file.