aboutsummaryrefslogtreecommitdiff
path: root/gcc/except.c
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-06-25 18:31:23 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-06-25 18:47:23 +0100
commit9b6c65c754f2b2a78f5353219ec62817064e0d24 (patch)
tree761a79c58e3521507d40240ff27043fe1db56718 /gcc/except.c
parent7ab7fa1b51cb7227e051842bcb971b95c962327a (diff)
downloadgcc-9b6c65c754f2b2a78f5353219ec62817064e0d24.zip
gcc-9b6c65c754f2b2a78f5353219ec62817064e0d24.tar.gz
gcc-9b6c65c754f2b2a78f5353219ec62817064e0d24.tar.bz2
libstdc++: Fix exception handling in std::ostream seek functions
N3168 added the requirement that the [ostream.seeks] functions create a sentry object. Nothing in the requirements of those functions says anything about catching exceptions and setting badbit. As well as not catching exceptions, this change results in another observable behaviour change. Previously seeking on a stream with eofbit set would work (as long as badbit and failbit weren't set). The construction of a sentry causes failbit to be set when eofbit is set, which causes the seek to fail. It is necessary to clear the eofbit before seeking now. libstdc++-v3/ChangeLog: * include/bits/ostream.tcc (sentry): Only set failbit if badbit is set, not if eofbit is set. (tellp, seekp, seekp): Create sentry object. Do not set badbit on exceptions. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: Adjust expected behaviour. * testsuite/27_io/basic_ostream/seekp/wchar_t/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/tellp/wchar_t/exceptions_badbit_throw.cc: Likewise. * testsuite/27_io/basic_ostream/seekp/char/n3168.cc: New test. * testsuite/27_io/basic_ostream/seekp/wchar_t/n3168.cc: New test. * testsuite/27_io/basic_ostream/tellp/char/n3168.cc: New test. * testsuite/27_io/basic_ostream/tellp/wchar_t/n3168.cc: New test.
Diffstat (limited to 'gcc/except.c')
0 files changed, 0 insertions, 0 deletions