You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally reported as DevCom-10555755 / VSO-1939195 / AB#1939195 . I've cleaned up the repro and especially the Standardese citations, so I believe this is a bug.
D:\GitHub\STL\out\x64>type meow.cpp
#include<cassert>
#include<iostream>
#include<sstream>
#include<stdexcept>usingnamespacestd;classMyStreamBuf : publicstreambuf {
protected:// N4971 [streambuf.virt.get]/1-2:// "streamsize showmanyc();// Returns: An estimate of the number of characters available in the sequence, or -1.// If it returns a positive value, then successive calls to underflow() will not return// traits::eof() until at least that number of characters have been extracted from the stream.// If showmanyc() returns -1, then calls to underflow() or uflow() will fail. [Note 277]// Default behavior: Returns zero."// Note 277:// "underflow or uflow can fail by throwing an exception prematurely. The intention// is not only that the calls will not return eof() but that they will return "immediately"."
int_type underflow() override {
throwruntime_error("WOOF");
}
};
intmain() {
MyStreamBuf rdbuf;
ostringstream oss;
assert(oss.exceptions() == ios_base::goodbit);
try {
// N4971 [ostream.inserters]/8-9:// "basic_ostream& operator<<(basic_streambuf<charT, traits>* sb);// Gets characters from sb and inserts them in *this. Characters are// read from sb and inserted until any of the following occurs:// [...]// - an exception occurs while getting a character from sb.// If the function inserts no characters, it calls setstate(failbit) (which// may throw ios_base::failure ([iostate.flags])). If an exception was thrown// while extracting a character, the function sets failbit in the error state,// and if failbit is set in exceptions() the caught exception is rethrown."
oss << &rdbuf;
cout << "No exception observed in main().\n";
} catch (const runtime_error&) {
cout << "Caught runtime_error in main().\n";
}
assert(oss.rdstate() == ios_base::failbit);
}
Originally reported as DevCom-10555755 / VSO-1939195 / AB#1939195 . I've cleaned up the repro and especially the Standardese citations, so I believe this is a bug.
libstdc++ and libc++ print "No exception observed in main()." as shown by https://godbolt.org/z/Yq3noKn8s .
The text was updated successfully, but these errors were encountered: