Skip to content

Commit a7d8869

Browse files
authored
Merge 2019-02 CWG Motion 10
P1009R2 Array size deduction in new-expressions Fixes #2690.
2 parents f29e482 + c9074b5 commit a7d8869

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

source/expressions.tex

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4433,7 +4433,7 @@
44334433

44344434
\begin{bnf}
44354435
\nontermdef{noptr-new-declarator}\br
4436-
\terminal{[} expression \terminal{]} \opt{attribute-specifier-seq}\br
4436+
\terminal{[} \opt{expression} \terminal{]} \opt{attribute-specifier-seq}\br
44374437
noptr-new-declarator \terminal{[} constant-expression \terminal{]} \opt{attribute-specifier-seq}
44384438
\end{bnf}
44394439

@@ -4547,9 +4547,6 @@
45474547
\grammarterm{noptr-new-declarator} shall be a converted constant
45484548
expression\iref{expr.const} of type \tcode{std::size_t} and
45494549
shall evaluate to a strictly positive value.
4550-
\indextext{\idxcode{new}}%
4551-
The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is
4552-
implicitly converted to \tcode{std::size_t}.
45534550
\begin{example}
45544551
Given the definition \tcode{int n = 42},
45554552
\tcode{new float[n][5]} is well-formed (because \tcode{n} is the
@@ -4559,9 +4556,20 @@
45594556
\end{example}
45604557

45614558
\pnum
4559+
If the \grammarterm{type-id} or \grammarterm{new-type-id}
4560+
denotes an array type of unknown bound\iref{dcl.array},
4561+
the \grammarterm{new-initializer} shall not be omitted;
4562+
the allocated object is an array with \tcode{n} elements,
4563+
where \tcode{n} is determined from the number of initial elements
4564+
supplied in
4565+
the \grammarterm{new-initializer}~(\ref{dcl.init.aggr}, \ref{dcl.init.string}).
4566+
4567+
\pnum
4568+
\indextext{\idxcode{new}}%
4569+
If the \grammarterm{expression} in a \grammarterm{noptr-new-declarator}
4570+
is present, it is implicitly converted to \tcode{std::size_t}.
45624571
\indextext{function!allocation}%
4563-
The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is
4564-
erroneous if:
4572+
The \grammarterm{expression} is erroneous if:
45654573

45664574
\begin{itemize}
45674575
\item

0 commit comments

Comments
 (0)