Topic: destruction of objects
Author: stanl@cbnewsm.att.com (stanley.b.lippman)
Date: 9 Aug 91 13:31:29 GMT Raw View
In article <82557@brunix.UUCP> sdm@cs.brown.edu (Scott Meyers) writes:
>In the second edition of Lippman's C++ Primer, he discusses what happens
>when the compiler sees this declaration:
>
> X x = 10;
>
>He talks about constructor calls, etc., and then he makes this statement,
>on pages 503-4:
>
> Finally, if X defines a destructor, the compiler must insert a call to
> it AT THE POINT IMMEDIATELY FOLLOWING THE LAST USE OF x. [Emphasis
> mine.]
>
>This seems to be a good bit stronger than the ARM requirement that the
>destructor for an object be called sometime between its last use and when
>it goes out of scope.
*** remind me to have scott read __everything__ i write from now on ...
there are certainly times when the compiler must immediately
destroy a temporary object, such as one occurring within the
the right hand side of &&.
In general, however, scott is absolutely right.
The phrase above should read ``at a point following the last use...''
The insertion of immediately must have been made by my editorial
assistant G.R. Emlin.