From 1685143797112689095
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,c79715c6d9945c29
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-11-18 01:01:26 PST
Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!forney.berkeley.edu!jbuck
From: jbuck@forney.berkeley.edu (Joe Buck)
Newsgroups: comp.std.c++
Subject: Re: return values and destructors
Date: 18 Nov 1992 21:47:06 GMT
Organization: U. C. Berkeley
Lines: 30
Message-ID: <1eedkqINN9i2@agate.berkeley.edu>
References: <BxMxxB.CMp@scd.hp.com> <1992Nov17.204640.9222@microsoft.com> <Bxx2uD.42x@scd.hp.com>
NNTP-Posting-Host: forney.berkeley.edu


In article <1992Nov17.204640.9222@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
>>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.

In article <Bxx2uD.42x@scd.hp.com> vinoski@ch.apollo.hp.com (Stephen Vinoski) writes:
>I don't think that "confusion" is the correct term since I also
>believe this to be a compiler bug.  My comment about thrown objects
>was an attempt to show how ridiculous it is for return expressions to
>be affected by destructors of local objects.  Remember, not everyone
>posting to this thread agrees that this is a problem.

Well, I was one of those who said that it wasn't a problem, because I
found the original example posted a bit contrived.  But Jim Adcock's
argument has convinced me that I was wrong; the argument to "return"
has to be evaluated before the destructors are evaluated, and the
sloppiness on this issue that I was advocating (e.g. assume nothing
about destructors that affect the return value in this way) was wrong
and would make the exceptions facility very difficult to use.

The ARM and draft standard could make this clearer.



--
Joe Buck	jbuck@ohm.berkeley.edu


