Problem inheriting from std::exception
Denis Vakatov
vakatov@ncbi.nlm.nih.gov
Sat Feb 24 14:34:00 GMT 2001
> From: Jason Merrill <jason@redhat.com>
> Date: 24 Feb 2001 09:39:53 +0000
>
> >>>>> "Denis" == Denis Vakatov <vakatov@ncbi.nlm.nih.gov> writes:
>
> > I believe it's because of the way GCC delivers the exception (or at least
> > used to deliver it yet several months ago).
>
> > It actually delivers a *copy* of the original exception, and not the original.
>...
> > Other compilers (like your Digital one) may (and often do) deliver
> > exceptions in a different way, sometimes without making extra copy(es)
> > of the original exception object...
>
> The GCC semantics are mandated by the C++ standard; if Digital doesn't make
> a copy, that's a bug.
-- I may just have an obsolete version of the C++ Standard
(www.cygnus.com/misc/wp/dec96pub/except.html#except.throw),
but it says (or at least used to say):
| 4 The memory for the temporary copy of the exception being thrown is
| allocated in an unspecified way, except as noted in
| _basic.stc.dynamic.allocation_.
| ......
| If the use of the temporary object can be eliminated without
| changing the meaning of the program except for the execution of con-
| structors and destructors associated with the use of the temporary
| object (_class.temporary_), then the exception in the handler can be
| initialized directly with the argument of the throw expression.
which effectively means that it is (was?) not MANDATED by the Standard
for the compiler to make a copy of exception.
And, in my letter I never even hinted ;-) that making a copy was GCC bug;
I just explained what could cause Craig's problem...
Take care,
Denis
More information about the Libstdc++
mailing list