[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #15 from Aldy Hernandez --- Author: aldyh Date: Wed Sep 13 15:49:50 2017 New Revision: 252105 URL: https://gcc.gnu.org/viewcvs?rev=252105&root=gcc&view=rev Log: PR libstdc++/53984 fix failing test PR libstdc++/53984 * testsuite/27_io/basic_fstream/53984.cc: Fix test. Modified: branches/range-gen2/libstdc++-v3/ChangeLog branches/range-gen2/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 Jonathan Wakely changed: What|Removed |Added Target Milestone|--- |5.5
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 Jonathan Wakely changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #14 from Jonathan Wakely --- Fixed for 5.5, 6.5 and 7.3
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #13 from Jonathan Wakely --- Author: redi Date: Mon Sep 4 17:09:01 2017 New Revision: 251679 URL: https://gcc.gnu.org/viewcvs?rev=251679&root=gcc&view=rev Log: PR libstdc++/53984 handle exceptions in basic_istream::sentry Backport from mainline 2017-07-25 Jonathan Wakely PR libstdc++/53984 * include/bits/basic_ios.h (basic_ios::_M_setstate): Adjust comment. * include/bits/istream.tcc (basic_istream::sentry): Handle exceptions during construction. * include/std/istream: Adjust comments for formatted input functions and unformatted input functions. * testsuite/27_io/basic_fstream/53984.cc: New. * testsuite/27_io/basic_istream/sentry/char/53984.cc: New. Added: branches/gcc-5-branch/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc branches/gcc-5-branch/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/53984.cc Modified: branches/gcc-5-branch/libstdc++-v3/ChangeLog branches/gcc-5-branch/libstdc++-v3/include/bits/basic_ios.h branches/gcc-5-branch/libstdc++-v3/include/bits/istream.tcc branches/gcc-5-branch/libstdc++-v3/include/std/istream
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #12 from Jonathan Wakely --- Author: redi Date: Mon Sep 4 16:52:25 2017 New Revision: 251675 URL: https://gcc.gnu.org/viewcvs?rev=251675&root=gcc&view=rev Log: PR libstdc++/53984 handle exceptions in basic_istream::sentry Backport from mainline 2017-07-25 Jonathan Wakely PR libstdc++/53984 * include/bits/basic_ios.h (basic_ios::_M_setstate): Adjust comment. * include/bits/istream.tcc (basic_istream::sentry): Handle exceptions during construction. * include/std/istream: Adjust comments for formatted input functions and unformatted input functions. * testsuite/27_io/basic_fstream/53984.cc: New. * testsuite/27_io/basic_istream/sentry/char/53984.cc: New. Added: branches/gcc-6-branch/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc branches/gcc-6-branch/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/53984.cc Modified: branches/gcc-6-branch/libstdc++-v3/ChangeLog branches/gcc-6-branch/libstdc++-v3/include/bits/basic_ios.h branches/gcc-6-branch/libstdc++-v3/include/bits/istream.tcc branches/gcc-6-branch/libstdc++-v3/include/std/istream
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #12 from Jonathan Wakely --- Author: redi Date: Mon Aug 14 12:14:01 2017 New Revision: 251089 URL: https://gcc.gnu.org/viewcvs?rev=251089&root=gcc&view=rev Log: PR libstdc++/53984 handle exceptions in basic_istream::sentry Backport from mainline 2017-07-25 Jonathan Wakely PR libstdc++/53984 * include/bits/basic_ios.h (basic_ios::_M_setstate): Adjust comment. * include/bits/istream.tcc (basic_istream::sentry): Handle exceptions during construction. * include/std/istream: Adjust comments for formatted input functions and unformatted input functions. * testsuite/27_io/basic_fstream/53984.cc: New. * testsuite/27_io/basic_istream/sentry/char/53984.cc: New. Added: branches/gcc-7-branch/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc branches/gcc-7-branch/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/53984.cc Modified: branches/gcc-7-branch/libstdc++-v3/ChangeLog branches/gcc-7-branch/libstdc++-v3/include/bits/basic_ios.h branches/gcc-7-branch/libstdc++-v3/include/bits/istream.tcc branches/gcc-7-branch/libstdc++-v3/include/std/istream
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #11 from Jonathan Wakely --- Author: redi Date: Wed Jul 26 22:06:13 2017 New Revision: 250594 URL: https://gcc.gnu.org/viewcvs?rev=250594&root=gcc&view=rev Log: PR libstdc++/53984 fix failing test PR libstdc++/53984 * testsuite/27_io/basic_fstream/53984.cc: Fix test. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 Jonathan Wakely changed: What|Removed |Added Known to work||8.0 --- Comment #10 from Jonathan Wakely --- Fixed on trunk. We might want to backport this to active branches too.
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #9 from Jonathan Wakely --- Author: redi Date: Tue Jul 25 20:36:06 2017 New Revision: 250545 URL: https://gcc.gnu.org/viewcvs?rev=250545&root=gcc&view=rev Log: PR libstdc++/53984 handle exceptions in basic_istream::sentry PR libstdc++/53984 * include/bits/basic_ios.h (basic_ios::_M_setstate): Adjust comment. * include/bits/istream.tcc (basic_istream::sentry): Handle exceptions during construction. * include/std/istream: Adjust comments for formatted input functions and unformatted input functions. * testsuite/27_io/basic_fstream/53984.cc: New. * testsuite/27_io/basic_istream/sentry/char/53984.cc: New. Added: trunk/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc trunk/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/53984.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/basic_ios.h trunk/libstdc++-v3/include/bits/istream.tcc trunk/libstdc++-v3/include/std/istream
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #8 from Jonathan Wakely --- 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 #include 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.
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #7 from Jonathan Wakely --- Eventually. I tried removing the throws and got a bunch of test failures: FAIL: 27_io/basic_filebuf/overflow/char/9182-2.cc execution test FAIL: 27_io/basic_filebuf/seekoff/wchar_t/3.cc execution test FAIL: 27_io/basic_filebuf/seekpos/wchar_t/1.cc execution test FAIL: 27_io/basic_filebuf/sync/char/9182-1.cc execution test 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 FAIL: 27_io/basic_filebuf/underflow/wchar_t/11603.cc execution test
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 David Rodriguez Ibeas changed: What|Removed |Added CC||dibeas at ieee dot org --- Comment #6 from David Rodriguez Ibeas --- Still failling 6.2. Any plans to look at this one?
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #5 from Roger Orr --- Still fails with gcc 6.1 Are there any plans on how (and when) to fix this, fairly serious, fault?
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #4 from Igor --- This is a really evil bug. I wonder why the Importance is not higher. This may crash programs that try to read many /proc files on Linux. ~$ g++ -x c++ -o test - < #include int main(int argc, char *argv[]) { std::ifstream in(argv[1]); sleep(4); std::string s; if (in) in >> s; return 0; } EOF ~$ sleep 2 & ./test "/proc/${!}/stat" terminate called after throwing an instance of 'std::ios_base::failure' what(): basic_filebuf::underflow error reading the file Aborted (core dumped)
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 Tomalak Geret'kal changed: What|Removed |Added CC||tom at kera dot name --- Comment #3 from Tomalak Geret'kal --- Another testcase was proposed under the following Stack Overflow question: http://stackoverflow.com/q/20371956/560648 The answer to that question was a link to this bug.
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2012-07-16 Ever Confirmed|0 |1 --- Comment #2 from Jonathan Wakely 2012-07-16 17:26:39 UTC --- Confirmed, I'm not sure filebuf::underflow should throw on invalid byte sequences either.
[Bug libstdc++/53984] iostream operation throwing exception when exceptions not enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53984 --- Comment #1 from Pete Chapman 2012-07-16 17:00:10 UTC --- Even simpler: --- #include int main() { std::ifstream in("."); int x; if (in) in >> x; } ---