https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145
Bug ID: 66145 Summary: std::ios_base::failure objects thrown from libstdc++.so use old ABI Product: gcc Version: 5.0 Status: UNCONFIRMED Keywords: ABI Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org CC: doko at gcc dot gnu.org Target Milestone: --- Using the new cxx11 ABI in GCC5 (and trunk) the exception here isn't caught: #define _GLIBCXX_USE_CXX11_ABI 1 #include <fstream> #include <limits> int main() { std::fstream f; f.exceptions(std::ios::badbit); try { f.pword(std::numeric_limits<int>::max()); } catch (const std::ios_base::failure&) { return 0; } throw 1; } terminate called after throwing an instance of 'std::ios_base::failure' what(): ios_base::_M_grow_words is not valid Aborted (core dumped) This is because src/c++11/functexcept.cc has: // We don't want to change the type thrown by __throw_ios_failure (yet?) #define _GLIBCXX_USE_CXX11_ABI 0 I actually planned to change it for GCC5 but missed it. If we change the ABI used to compile functexcept.cc then the code above would fail when using the old ABI instead. One option to make both forms work would be to hack the EH runtime to make handlers for std::ios_base::failure able to catch std::ios_base::failure[abi:cxx11] objects, and vice versa, creating an object of the other type on the fly.