This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

418. exceptions thrown during iostream cleanup

Section: [ios.init] Status: NAD Submitter: Martin Sebor Opened: 2003-09-18 Last modified: 2021-06-06

Priority: Not Prioritized

View all other issues in [ios.init].

View all issues with NAD status.


The dtor of the ios_base::Init object is supposed to call flush() on the 6 standard iostream objects cout, cerr, clog, wcout, wcerr, and wclog. This call may cause an exception to be thrown., p3 prohibits all library destructors from throwing exceptions.

The question is: What should this dtor do if one or more of these calls to flush() ends up throwing an exception? This can happen quite easily if one of the facets installed in the locale imbued in the iostream object throws.

[Kona: We probably can't do much better than what we've got, so the LWG is leaning toward NAD. At the point where the standard stream objects are being cleaned up, the usual error reporting mechanism are all unavailable. And exception from flush at this point will definitely cause problems. A quality implementation might reasonably swallow the exception, or call abort, or do something even more drastic.]

[ See 397 and 622 for related issues. ]

[ 2009-07 Frankfurt ]

Moved to NAD, no consensus for change.

Proposed resolution: