When should value parameters be destroyed?

Daveed Vandevoorde daveed at edg.com
Thu Sep 28 21:35:14 UTC 2000


It's most explicit in [expr.call] 5.2.2/4:

	[...] The lifetime of a parameter ends when the function in which
	it is defined returns. The initialization and destruction of each
	parameter occurs within the context of the calling function. 
	[Example: the access of the constructor, conversion functions or 
	destructor is checked at the point of call in the calling function. 
	If a constructor or destructor for a function parameter throws an 
	exception, the search for a handler starts in the scope of the 
	calling function; in particular, if the function called has a 
	function-try-block (clause except) with a handler that could handle 
	the exception, this handler is not considered. ]

(It may not be the most optimal answer, but it seem pretty unambiguous.)

	Daveed


mendell at ca.ibm.com wrote:
> 
> >From today's meeting, it turns out that g++ destroys value parameters in the called
> function, and that is what the current ABI states.  Our compiler (and I think HP's)
> destroyes them in the caller routine.  I asked our 'standards guy', and got back the
> following:
> 
>    Sentence 3, paragraph 3 of 12.2: 'Temporary object are destroyed as the
>    last step in evaluating the full-expression(1.8) that (lexically) contains
>    the point where they were created.'
> 
>    Also see paragraph 12 and 16 of 1.8 and the note associated with
>    paragraph 16.
> 
> I believe that this implies that you are NOT allowed to destroy the temporary in the
> called routine, but must destroy it in the caller.    This would mean a change to
> our ABI, and would explain the reason that we pass classes with non-trivial
> destructors by reference (unlike g++).
> 
> Mark




More information about the cxx-abi-dev mailing list