Topic: Destruction of partially-constructed heap objects.
Author: afcjlloyd@aol.com (AFC JLloyd)
Date: 25 Oct 1994 22:31:04 -0400 Raw View
The 20 September 1994 draft states the following (section 15.2, paragraph
2):
"An object that is partially constructed will have destructors executed
only for its fully constructed subobjects. Should a constructor for an
automatic array throw an exception, only the constructed elements of that
array will be destroyed. If the object or array was allocated in a
new-expression, the storage occupied by that object is sometimes deleted
also (5.3.4)."
Section 5.3.4 , paragraph 18 says:
"If the constructor throws an exception and the new-expression does not
contain a new-placement, then the deallocation function (3.6.3.2, 12.5) is
used to free the memory in which the object was being constructed, after
which the exception continues to propogate in the context of the
new-expression."
These two paragraphs do not explicitly state that fully-constructed
subobjects of partially-constructed heap-objects are destroyed before the
storage is deallocated, and they seem to leave open the possibility that
partially constructed sub-objects are not destroyed. Could the committee
please clarify this in a future draft? A reply here in the meantime would
be greatly appreciated.
Jim Lloyd
afcjlloyd@aol.com -or- jim_lloyd@powertalk.apple.com
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Sat, 29 Oct 1994 09:14:09 GMT Raw View
afcjlloyd@aol.com (AFC JLloyd) writes:
>These two paragraphs do not explicitly state that fully-constructed
>subobjects of partially-constructed heap-objects are destroyed before the
>storage is deallocated
That is certainly the intent, although you are right that the wording
should be clearer.
>and they seem to leave open the possibility that
>partially constructed sub-objects are not destroyed.
That is quite deliberate - partially constructed sub-objects *must not*
be destroyed, since they have not been fully constructed.
--
Fergus Henderson - fjh@munta.cs.mu.oz.au
Author: afcjlloyd@aol.com (AFC JLloyd)
Date: 29 Oct 1994 14:44:02 -0400 Raw View
fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
>afcjlloyd@aol.com (AFC JLloyd) writes:
>
>>These two paragraphs do not explicitly state that fully-constructed
>>subobjects of partially-constructed heap-objects are destroyed before
the
>>storage is deallocated
>
>That is certainly the intent, although you are right that the wording
>should be clearer.
I'm glad to hear that is the intent. I asked about this over a year ago,
and was informally told that it was the committee's intent. The 20 Sep
draft is the first draft I have seen in quite some time; I had hoped it
would
contain an unambiguous statement for this by now.
>
>>and they seem to leave open the possibility that
>>partially constructed sub-objects are not destroyed.
>
>That is quite deliberate - partially constructed sub-objects *must not*
>be destroyed, since they have not been fully constructed.
I beg your pardon; I meant to say:
"... and they seem to leave open the possiblity that fully
constructed sub-objects [of partially constructed heap objects]
are not destroyed."
Thanks for your reply.
Jim Lloyd - afcjlloyd@aol.com
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Mon, 31 Oct 1994 16:40:40 GMT Raw View
In article <38kf18$sag@newsbf01.news.aol.com> afcjlloyd@aol.com (AFC JLloyd) writes:
>The 20 September 1994 draft states the following (section 15.2, paragraph
>2):
>
>
>These two paragraphs do not explicitly state that fully-constructed
>subobjects of partially-constructed heap-objects are destroyed before the
>storage is deallocated, and they seem to leave open the possibility that
>partially constructed sub-objects are not destroyed. Could the committee
>please clarify this in a future draft? A reply here in the meantime would
>be greatly appreciated.
Each fully constructed subobject with a non-trivial
destructor body is first disassembled by executing
that body.
Each partially or fully constructed subobject is then
destroying by recursively applying the first step
to each fully or partially constructed member or base.
The recursion is terminated because in the end
you have scalar objects which do not require destruction.
The order of destruction is "roughly" the reverse of
construction. Exactly what this means is a current
topic of debate.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd,
81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21
NSW 2037, AUSTRALIA Phone: 61-2-566-2189