Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


938. Initializer lists and array new

Section:9.5.2  [dcl.init.aggr]    Status:C++11    Submitter:Alisdair Meredith    Date:12 July, 2009

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

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

Aninitializer-list is ill-formed if the number ofinitializer-clauses exceeds the number of members or elementsto initialize.

However, in anew-expression, the number of elements to beinitialized is potentially unknown at compile time. How should anoverly-longinitializer-list in anew-expression be treated?

Notes from the August, 2010 meeting:

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

Proposed resolution (January, 2011):

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

When the value of theexpression in anoptr-new-declarator is zero, the allocation function is calledto allocate an array with no elements. If the value of thatexpression is less than zero or such that the size of theallocated object would exceed the implementation-defined limit,or if thenew-initializer is abraced-init-list forwhich the number ofinitializer-clauses exceeds the number ofelements to initialize, no storage is obtained and thenew-expression terminates by throwing an exception of a typethat would match a handler (14.4 [except.handle]) of typestd::bad_array_new_length (17.6.4.2 [new.badlength]).



[8]ページ先頭

©2009-2026 Movatter.jp