Title
Initializer lists and array new
Status
c++11
Section
9.4.2 [dcl.init.aggr]
Submitter
Alisdair Meredith

Created on 2009-07-12.00:00:00 last changed 96 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting.]

Date: 2011-01-15.00:00:00

Proposed resolution (January, 2011):

Change 7.6.2.8 [expr.new] paragraph 7 as follows:

When the value of the expression in a noptr-new-declarator is zero, the allocation function is called to allocate an array with no elements. If the value of that expression is less than zero or such that the size of the allocated object would exceed the implementation-defined limit, or if the new-initializer is a braced-init-list for which the number of initializer-clauses exceeds the number of elements to initialize, no storage is obtained and the new-expression terminates by throwing an exception of a type that would match a handler (14.4 [except.handle]) of type std::bad_array_new_length (17.6.4.2 [new.badlength]).
Date: 2010-08-15.00:00:00

Notes from the August, 2010 meeting:

The consensus of the CWG was that this case should throw an exception at runtime.

Date: 2009-07-12.00:00:00

9.4.2 [dcl.init.aggr] paragraph 4 says,

An initializer-list is ill-formed if the number of initializer-clauses exceeds the number of members or elements to initialize.

However, in a new-expression, the number of elements to be initialized is potentially unknown at compile time. How should an overly-long initializer-list in a new-expression be treated?

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3347
2011-04-10 00:00:00adminsetstatus: tentatively ready -> fdis
2011-02-28 00:00:00adminsetmessages: + msg3231
2011-02-28 00:00:00adminsetstatus: drafting -> tentatively ready
2010-08-23 00:00:00adminsetmessages: + msg2854
2010-08-23 00:00:00adminsetstatus: open -> drafting
2009-07-12 00:00:00admincreate