Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<istream>/<ostream> : seekg() and seekp() must catch and rethrow internal io exceptions #1858

Closed
calvincramer opened this issue Apr 19, 2021 · 1 comment · Fixed by #2033
Closed
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@calvincramer
Copy link

Describe the bug
seekg() and seekp() must catch and rethrow internal io exceptions. If an internal io exception occurs, the bad bit must be set:
See: http://www.cplusplus.com/reference/istream/istream/seekg/ at the bottom in the "Exception Safety" section.

Expected behavior
seekg() and seekp() must catch and rethrow internal io exceptions.

STL version
current

  • Option 2: git commit hash
    main

Additional context
Both llvm and gcc's c++ standard libraries do this:
https://github.com/google/libcxx/blob/master/include/istream#L1370
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/istream.tcc#L877

This issue was found from a boost iostreams test case: https://github.com/boostorg/iostreams/blob/develop/test/stream_state_test.cpp
Where a phony "error_device" implements internal io operations read(), write() and seek() which each throw an exception. These functions are ultimately called from seekg() and seekp() in istream and ostream.

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Apr 20, 2021
@miscco
Copy link
Contributor

miscco commented Jul 1, 2021

I am currently writing some additional tests for the fixes

From what I understand we have bugs in

istream::sync
istream::seekg
istream::seekg
istream::tellg

ostream::flush
ostream::seekp
ostream::seekp
ostream::tellp

miscco added a commit to miscco/STL that referenced this issue Jul 1, 2021
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants