<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - libc++ stringstream extraction doesn't properly throw exceptions"
href="http://llvm.org/bugs/show_bug.cgi?id=19518">19518</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>libc++ stringstream extraction doesn't properly throw exceptions
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>benpope81@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - no exceptions are thrown for stringstream"
href="show_bug.cgi?id=15949">bug15949</a>#c1 appears to be relevant.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>