]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Avoid intercepting exception in ostream::write
authorJonathan Wakely <jwakely@redhat.com>
Fri, 25 Jun 2021 17:31:23 +0000 (18:31 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 25 Jun 2021 17:47:44 +0000 (18:47 +0100)
commit4a52cf2eb9d6864ad85674ab56838e0d9ce27926
treec6d5721c0a4ccfbe7c739b5856e70635da9ea805
parentf8c5b542f6cb6a947600e34420565ac67486ea14
libstdc++: Avoid intercepting exception in ostream::write

Currently if ostream::write fails and sets badbit and that causes an
exception, we will catch the exception, set badbit again, and rethrow
the exception.

This change delays setting badbit until after the try-catch block, so
that if it causes an exception we don't need to catch and rethrow it.

This removes the last remaining use of _M_write, so it can be made
private (or removed entirely for versioned namespace builds, where ABI
compatibility is not required). All other uses of _M_write were replaced
by calls to __ostream_insert, so make _M_write use that too.

libstdc++-v3/ChangeLog:

* include/bits/ostream.tcc (basic_ostream::write): Call sputn
directly instead of using _M_write. Do setstate(__err) all
outside the try-catch block.
* include/std/ostream (basic_ostream::_M_write): Declare
private. Use __ostream_insert. Do not define for the versioned
namespace.
libstdc++-v3/include/bits/ostream.tcc
libstdc++-v3/include/std/ostream
This page took 0.057519 seconds and 6 git commands to generate.