[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 Jonathan Wakely changed: What|Removed |Added Status|WAITING |RESOLVED Resolution|--- |INVALID --- Comment #7 from Jonathan Wakely --- Yes, closing.
[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 Martin Liška changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2020-01-29 CC||marxin at gcc dot gnu.org, ||redi at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #6 from Martin Liška --- @Jonathan: Can we close this as invalid?
[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 Liu Hao changed: What|Removed |Added CC||lh_mouse at 126 dot com --- Comment #5 from Liu Hao --- This may be inconsistency (if not necessarily a defect) in the C++ standard, since both `basic_ostream::{put,write}`, as UnformattedOutputFunctions, set `badbit` in case of output failure, but `operator<<(basic_streambuf*)` doesn't. Nevertheless GCC is doing the right thing and conform to all standards. It should also be noted that if `operator<<(basic_streambuf*)` could not extract any character, `failbit` is set on the output stream. Thus correct use of this function requires a loop, as follows: ``` bool copy_stream(std::ostream& os, std::istream& is) { while(os && (is.rdbuf()->sgetc() != std::istream::traits_type::eof())) os << is.rdbuf(); return !!os; } ``` Anyway, it is not a bug in libstdc++.
[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 --- Comment #4 from yinghui --- (In reply to TC from comment #3) > Looks NAD to me. > > http://eel.is/c++draft/ostream.inserters#8.2 doesn't say that we set any bit > in that case. Contrast with http://eel.is/c++draft/ostream.unformatted#3 and > http://eel.is/c++draft/ostream.unformatted#5.2 so, seems like this is a bug of the c++ standard? if an i/o function can't report failure on i/o operation failure, it can not be used in any serious code.
[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 TC changed: What|Removed |Added CC||rs2740 at gmail dot com --- Comment #3 from TC --- Looks NAD to me. http://eel.is/c++draft/ostream.inserters#8.2 doesn't say that we set any bit in that case. Contrast with http://eel.is/c++draft/ostream.unformatted#3 and http://eel.is/c++draft/ostream.unformatted#5.2
[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 --- Comment #2 from yinghui --- (In reply to Jonathan Wakely from comment #1) > GCC 4.9.2 has been unsupported for several years. but both the code and the problem still keeps exactly the same. I have seen many c++ code write 'os << is.rdbuf()` as a stream copy idiom, and this may silently write corrupted data in case like disk full.
[Bug libstdc++/91653] ostream::operator<<(streambuf*) should fail the ostream when write output stream error but not
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91653 --- Comment #1 from Jonathan Wakely --- GCC 4.9.2 has been unsupported for several years.