This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1956. Reuse of storage of automatic variables

Section: 6.7.5.4  [basic.stc.auto]     Status: CD4     Submitter: Daniel Krügler     Date: 2014-06-29

[Moved to DR at the May, 2015 meeting.]

According to 6.7.5.4 [basic.stc.auto] paragraph 3,

If a variable with automatic storage duration has initialization or a destructor with side effects, it shall not be destroyed before the end of its block, nor shall it be eliminated as an optimization even if it appears to be unused, except that a class object or its copy/move may be eliminated as specified in 11.4.5.3 [class.copy.ctor].

This is intended to be a requirement for the implementation, but it could be read as prohibiting the reuse of the storage of an automatic variable by the program using a placement new-expression.

Proposed resolution (November, 2014):

Change 6.7.5.4 [basic.stc.auto] paragraph 3 as follows:

If a variable with automatic storage duration has initialization or a destructor with side effects, it an implementation shall not be destroyed destroy it before the end of its block, nor shall it be eliminated eliminate it as an optimization, even if it appears to be unused, except that a class object or its copy/move may be eliminated as specified in 11.4.5.3 [class.copy.ctor].