[Bug libstdc++/66145] [5/6/7 Regression] std::ios_base::failure objects thrown from libstdc++.so use old ABI

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 20 19:12:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66145

--- Comment #23 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Boris Kolpackov from comment #21)
> Speaking of possible fixes, I had this crazy idea, not sure if it is
> technically possible though: what if libstdc++ throws some custom exception
> that derives from both version of ios::failure? This way both old and new
> ABI users will be able to catch it via the respective bases.

Apart from the difficulty of deriving from both types when they can't both be
declared at the same time (which could be solved) that solution would mean you
couldn't catch it with a handler of type const std::exception&, because the
base class would be ambiguous (it's not a virtual base).

Ideally I'd like it to be caught by handlers for std::ios_base::failure and
std::ios_base::failure[abi-tag:__cxx11] but I'm not sure that's possible.

Another option is to decide which to throw based on an environment variable, so
applications can choose whether they want the types thrown by the library to be
catchable by new code or old code.

But we might end up just throwing the new type, and saying old code needs to be
recompiled, or just to catch it as std::exception not std::ios_base::failure.


More information about the Gcc-bugs mailing list