Boost logo

Boost :

From: David Bergman (davidb_at_[hidden])
Date: 2002-08-14 14:23:39


I almost assumed you got it, just wanted to make sure, and also that
other readers understood that "subtlety".

Yes, compilers are quite intelligent when it comes to exceptions, they
need to carry around those exceptions intact, until they are caught with
no nested "throw;", then they can call the destructor and deallocate the
space.

/David

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: Wednesday, August 14, 2002 3:08 PM
To: boost_at_[hidden]
Subject: Re: [boost] std::exception -- Re:
Re:Re:Re:Re:AttemptingresolutionofThreads&ExceptionsIssue

From: "David Bergman" <davidb_at_[hidden]>
> Peter,
>
> One "subtle" note, though. You are aware that what you threw in 'f'
was
> actually the original object?

Yes, that was the point I was trying to make; I said in the original
post
that

> > >Well, I am not a compiler writer, but it seems to me that to
> implement
> > >"throw;" and "catch", the compiler already needs a way to copy the
> > >exception, complete with its original type. :-)

The exception is sliced by the catch() clause, but the original is
retained
and rethrown.

> The copy-constructor of X *does* indeed
> slice (they always do, them copy-constructors ;-). If you want to see
> the effect of this X object being passed up, and caught as an Y,
change
> the code to:

This calls abort() as expected. :-) You can't catch X as Y.

Either way, it seems clear to me that a compiler can transport an
exception
in the way we need (since it can generate clone() and throw_this()
functions - or an equivalent - for the correct type at the throw point,
even
if the actual exception handling implementation doesn't already require
them.)

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk