867. Valarray and value-initialization

Section: 29.6.2.2 [valarray.cons] Status: NAD Editorial Submitter: Alberto Ganesh Barbati Opened: 2008-07-20 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [valarray.cons].

View all issues with NAD Editorial status.

Discussion:

From 29.6.2.2 [valarray.cons], paragraph 2:

explicit  valarray(size_t);

The array created by this constructor has a length equal to the value of the argument. The elements of the array are constructed using the default constructor for the instantiating type T.

The problem is that the most obvious Ts for valarray are float and double, they don't have a default constructor. I guess the intent is to value-initialize the elements, so I suggest replacing:

The elements of the array are constructed using the default constructor for the instantiating type T.

with

The elements of the array are value-initialized.

There is another reference to the default constructor of T in the non-normative note in paragraph 9. That reference should also be replaced. (The normative wording in paragraph 8 refers to T() and so it doesn't need changes).

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to NAD Editorial.

Proposed resolution:

Change 29.6.2.2 [valarray.cons], paragraph 2:

explicit  valarray(size_t);

The array created by this constructor has a length equal to the value of the argument. The elements of the array are constructed using the default constructor for the instantiating type T value-initialized (9.4 [dcl.init]).

Change 29.6.2.8 [valarray.members], paragraph 9:

[Example: If the argument has the value -2, the first two elements of the result will be constructed using the default constructor value-initialized (9.4 [dcl.init]); the third element of the result will be assigned the value of the first element of the argument; etc. -- end example]