<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 --- - QoI: improve ios_base::failure implementation with specific error messages and codes"
href="http://llvm.org/bugs/show_bug.cgi?id=19198">19198</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>QoI: improve ios_base::failure implementation with specific error messages and codes
</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>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>seth.cantrell@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>n3337 27.5.3.1.1 Class ios_base::failure [ios::failure] paragraph 2 reads:
When throwing ios_base::failure exceptions, implementations should provide
values of ec that identify the specific reason for the failure. [ Note: Errors
arising from the operating system would typically be reported as
system_category() errors with an error value of the error number reported by
the operating system. Errors arising from within the stream library would
typically be reported as error_code(io_errc::stream, iostream_category()). —end
note ]
Currently libc++ reports only a generic error. For example the following
program:
#include <iostream>
#include <fstream>
int main() {
try {
std::ifstream f("doesn't exist");
f.exceptions(f.failbit);
}
catch (const std::ios_base::failure &e) {
std::cerr << "Caught an ios_base::failure.\n"
<< "Explanatory string: " << e.what() << '\n'
<< "Error code: " << e.code() << '\n';
}
}
Produces the output:
Caught an ios_base::failure.
Explanatory string: ios_base::clear: unspecified iostream_category error
Error code: iostream:1
Ideally it should produce output similar to that of the following program:
#include <iostream>
#include <cstdio>
int main() {
FILE *f = fopen("doesn't exist", "r");
if (!f) {
std::cerr << "null FILE* returned.\n";
perror("Explanatory string");
std::cerr << "Error code: " << errno << '\n';
}
}
which produces:
null FILE* returned.
Explanatory string: No such file or directory
Error code: 2</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>