This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


1566. Should new std::initializer_list<T> be ill-formed?

Section:  []     Status: NAD     Submitter: Steve Adamczyk     Date: 2012-10-10

A new-expression that creates an object whose type is a specialization of std::initializer_list initialized from an initializer list results in undefined behavior if the object survives past the end of the full-expression, when the lifetime of the underlying array object ends. Since such a new-expression is effectively useless, should it be made ill-formed?

Notes from the October, 2012 meeting:

The consensus of CWG was that this usage should be ill-formed.

Rationale (February, 2013):

Because the library emulation of std::is_constructible uses unevaluated new-expressions in the implementation, making a new of std::initializer_list ill-formed would give the wrong results for its constructibility. CWG determined that it would be acceptable to leave diagnosing of actual undefined behavior resulting from such constructs to the discretion of the implementation.