https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- FAIL: 27_io/basic_filebuf/overflow/char/9182-2.cc execution test This fails because it explicitly tests for an exception: try { fbuf1.sputn("ison", 4); fbuf1.pubsync(); VERIFY( false ); } catch (std::exception&) { } FAIL: 27_io/basic_filebuf/seekoff/wchar_t/3.cc execution test This also fails because it explicitly tests for an exception: try { // seekoff should flush the output sequence, which will fail // if the output buffer contains illegal characters. fb.pubseekoff(0, ios_base::cur); VERIFY( false ); } catch (std::exception&) { } FAIL: 27_io/basic_filebuf/seekpos/wchar_t/1.cc execution test This also tests for an exception: try { fb.pubseekpos(pos); VERIFY( false ); } catch (std::exception&) { } FAIL: 27_io/basic_filebuf/sync/char/9182-1.cc execution test And again: try { fbuf1.sputn("onne", 4); fbuf1.close(); VERIFY( false ); } catch (std::exception&) { } FAIL: 27_io/basic_filebuf/underflow/wchar_t/11544-1.cc execution test FAIL: 27_io/basic_filebuf/underflow/wchar_t/11544-2.cc execution test These both check for a bad stream state: VERIFY( in.good() ); in.get(); VERIFY( !in.good() ); VERIFY( in.bad() ); VERIFY( !in.eof() ); FAIL: 27_io/basic_filebuf/underflow/wchar_t/11603.cc execution test This fails because we have this: try { wfilebuf::int_type ret = fb.pub_underflow(); VERIFY( ret != wfilebuf::traits_type::eof() ); fb.sbumpc(); ret = fb.pub_underflow(); VERIFY( ret == wfilebuf::traits_type::eof() ); } catch (...) { } The first VERIFY is never reached because we throw in underflow. The test seems broken. Several of these tests are explicitly checking for exceptions, so the current behaviour of throwing on invalid byte sequences (comment 2) is clearly by design. I don't think the problem here is actually in basic_filebuf. I think filebuf is allowed to throw if there's an I/O error. I think the problem is that basic_istream::sentry doesn't handle exceptions that happen while skipping whitespace: #include <streambuf> #include <istream> struct SB : std::streambuf { int_type underflow() override { throw 1; } }; int main() { SB sb; std::istream is(&sb); int i; is >> i; } This seems easy to fix.