llvm-project
91b07569 - [libc++] Implement LWG4188: ostream::sentry destructor should handle exceptions (#241194)

Commit
23 hours ago
[libc++] Implement LWG4188: ostream::sentry destructor should handle exceptions (#241194) LWG4188 requires basic_ostream::sentry's destructor to set badbit when rdbuf()->pubsync() exits via an exception, matching the behavior when it returns -1, without letting the exception escape. libc++ already caught exceptions thrown by pubsync(), but left the stream state unchanged so the failure was silently dropped. This sets badbit in the catch handler as well, and uses __setstate_nothrow in both places so badbit in exceptions() doesn't cause a throw from the destructor. Adds a test covering failing and throwing sync() with and without badbit in the exception mask. Fixes #148200 --------- Signed-off-by: anant <anant1234466@gmail.com>
Author
Parents
Loading