Skip to content

Commit 44d9159

Browse files
jensmaurerzygoloid
authored andcommitted
P1009R2 Array size deduction in new-expressions
1 parent f29e482 commit 44d9159

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

source/expressions.tex

Lines changed: 12 additions & 3 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

@@ -4548,8 +4548,8 @@
45484548
expression\iref{expr.const} of type \tcode{std::size_t} and
45494549
shall evaluate to a strictly positive value.
45504550
\indextext{\idxcode{new}}%
4551-
The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is
4552-
implicitly converted to \tcode{std::size_t}.
4551+
If the \grammarterm{expression} in a \grammarterm{noptr-new-declarator}
4552+
is present, it is implicitly converted to \tcode{std::size_t}.
45534553
\begin{example}
45544554
Given the definition \tcode{int n = 42},
45554555
\tcode{new float[n][5]} is well-formed (because \tcode{n} is the
@@ -4558,6 +4558,15 @@
45584558
constant expression).
45594559
\end{example}
45604560

4561+
\pnum
4562+
If the \grammarterm{type-id} or \grammarterm{new-type-id}
4563+
denotes an array type of unknown bound\iref{dcl.array},
4564+
the \grammarterm{new-initializer} shall not be omitted;
4565+
the allocated object is an array with \tcode{n} elements,
4566+
where \tcode{n} is determined from the number of initial elements
4567+
supplied in
4568+
the \grammarterm{new-initializer}~(\ref{dcl.init.aggr}, \ref{dcl.init.string}).
4569+
45614570
\pnum
45624571
\indextext{function!allocation}%
45634572
The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is

0 commit comments

Comments
 (0)