From: David Abrahams (dave_at_[hidden])
Date: 2003-09-04 19:21:01
Bjarne Stroustrup <bs_at_[hidden]> writes:
>>>> From: David Abrahams [mailto:dave_at_[hidden]]
>>I guess Bjarne misunderstood the example. It had nothing to do with
>>what() at all.
> I did indeed. Sorry.
>>The problem is that if the exception has multiple std::exception base
>> catch(std::exception const&)
>>clause will fail to catch the exception at all. For people who are
>>trying to avoid using catch(...) I consider this to be a terrible
>>danger, since it happens only rarely, at runtime, and usually leads to
> That's bad. Shows what happens when you try to standardize on a single root -
> half :-)
> It does seem to be the case that if you want to
> (1) recommend all exceptions be derived from "std::exception
> (something I would be reluctant to do), and
> (2) recommend that you try to catch "all exceptions" using
> exception& (something I don't)
> then you have to recommend consistently using exception as a virtual
> I'd try to avoid "(1) plus (2)".
The problem with that workaround is that even if you don't do (1),
it's still a distinct possibility that any exceptions built using MI
will have multiple base subobjects in common, and even if you don't do
(2), people still want to be able to catch some exceptions using a
common base class... that is, after all, part of the whole idea behind
The more I think about the problem, the more I am convinced that the
guideline is appropriate anytime MI might be used in exception
hierarchies. We could of course discuss whether MI should be banned
in exception hierarchies. That's another guideline which IMO costs
little and gets us out of messes.
-- Dave Abrahams Boost Consulting www.boost-consulting.com