This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/71950] New: std::ios_base::failure.what() returns irrelevant error message
- From: "sytelus at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Jul 2016 17:32:32 +0000
- Subject: [Bug libstdc++/71950] New: std::ios_base::failure.what() returns irrelevant error message
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71950
Bug ID: 71950
Summary: std::ios_base::failure.what() returns irrelevant error
message
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: sytelus at gmail dot com
Target Milestone: ---
The what() method of exception class std::ios_base::failure should return
helpful error messages indicating why IO operation failed. At present it
returns irrelevant and unhelpful message such as "basic_ios::clear".
Below is the code to reproduce this bug:
#include <iostream>
#include <fstream>
int main() {
try {
std::ofstream flog;
flog.exceptions(flog.exceptions() | std::ios::failbit |
std::ifstream::badbit);
flog.open("~/bad/path/xyz.tsv", std::ios::trunc);
}
catch (const std::ios_base::failure &ex) {
std::cout << ex.what();
}
}