Article View: comp.std.c++
Article #1106Re: return values and destructors
From: Jim Adcock
Date: Tue, 17 Nov 1992 20:46
Date: Tue, 17 Nov 1992 20:46
19 lines
1573 bytes
1573 bytes
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. Likewise on return values. The return expression must be evaluated in scope which means it must be evaluated before the dtors so it must already *have* its value by the time scope is exited and dtors are executed. If the return object tries to get its value after dtoring its a compiler bug, since the dtoring implies scope has already been exited so then how could the return expression be being evaluated in scope?
Technical Details
Message-ID:
<1992Nov17.204640.9222@microsoft.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimadReferences:
<1dsevkINNe8t@agate.berkeley.edu> <1992Nov12.132254.1@vax1.bham.ac.uk> <BxMxxB.CMp@scd.hp.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad From: jimad@microsoft.com (Jim Adcock) Subject: Re: return values and destructors Message-ID: <1992Nov17.204640.9222@microsoft.com> Date: 17 Nov 92 20:46:40 GMT Organization: Microsoft Corporation References: <1dsevkINNe8t@agate.berkeley.edu> <1992Nov12.132254.1@vax1.bham.ac.uk> <BxMxxB.CMp@scd.hp.com> Lines: 20