From -4359679153919017511
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,c79715c6d9945c29
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-11-25 12:43:56 PST
Newsgroups: comp.std.c++
Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: return values and destructors
Message-ID: <1992Nov25.181555.6402@ucc.su.OZ.AU>
Sender: news@ucc.su.OZ.AU
Nntp-Posting-Host: extro.ucc.su.oz.au
Organization: MAXTAL P/L C/- University Computing Centre, Sydney
References: <1992Nov12.132254.1@vax1.bham.ac.uk> <BxMxxB.CMp@scd.hp.com> <1992Nov17.204640.9222@microsoft.com>
Date: Wed, 25 Nov 1992 18:15:55 GMT
Lines: 31

In article <1992Nov17.204640.9222@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
>In article <BxMxxB.CMp@scd.hp.com> vinoski@ch.apollo.hp.com (Stephen Vinoski) writes:
>|There is also a similar potential problem with exceptions and throw
>|statements; what happens if the value of the thrown object is affected
>|by the destructors executed due to stack unwinding before the throw
>|actually occurs?
>
>I still believe you're being confused by a compiler bug.  Can you quote
>ARM to support your position?  Seems clear to me that a throw expression
>has to be evaluated in scope, which means it must be evaluated before
>the destructors, since destructors occurs on exiting scope.  Once the
>throw expression has been evaluated, the throw object *has* its value, 
>and the destructors can do what they want without affecting its value.

	If you use a silly object mayhem could result. Consider throwing
an object containing a pointer to something on the stack that gets
unwound ...

	While we're talking of unwinding the stack in exceptions,
it seems to me (help !) that any pointers on the stack will just
evaporate and the objects they point to will NOT get deleted.

	So it would seem that using 'handle' classes and not
pointers on the stack is mandatory in the presence of exceptions.
Any comments ?

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------


