http://llvm.org/bugs/show_bug.cgi?id=19518
Bug ID: 19518
Summary: libc++ stringstream extraction doesn't properly throw
exceptions
Product: libc++
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Extracting a char from an empty stringstream sets badbit, failbit and eofbit,
but an exception is not thrown in many cases.
#include <sstream>
#include <iostream>
void test_iostate(std::ios_base::iostate state)
{
char c;
std::stringstream ss;
try
{
ss.exceptions(state);
ss >> c;
std::cout << "Didn't throw\n";
}
catch(std::ios_base::failure const& ex)
{
std::cout << "Threw: " << ex.what() << "\n";
}
}
int main()
{
test_iostate(std::ios_base::eofbit);
test_iostate(std::ios_base::badbit);
test_iostate(std::ios_base::failbit);
test_iostate(std::ios_base::eofbit|std::ios_base::badbit);
test_iostate(std::ios_base::eofbit|std::ios_base::failbit);
test_iostate(std::ios_base::badbit|std::ios_base::failbit);
test_iostate(std::ios_base::eofbit|std::ios_base::badbit|std::ios_base::failbit);
}
$ clang++ io_fail.cpp -stdlib=libc++ -lc++abi
$ ./a.out
Didn't throw
Didn't throw
Didn't throw
Threw: ios_base::clear: unspecified iostream_category error
Didn't throw
Threw: ios_base::clear: unspecified iostream_category error
Threw: ios_base::clear: unspecified iostream_category error
$ clang++ io_fail.cpp
$ ./a.out
Threw: basic_ios::clear
Didn't throw
Threw: basic_ios::clear
Threw: basic_ios::clear
Threw: basic_ios::clear
Threw: basic_ios::clear
Threw: basic_ios::clear
bug15949#c1 appears to be relevant.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs