Skip to content

P1009R2 Array size deduction in new-expressions #2731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4433,7 +4433,7 @@

\begin{bnf}
\nontermdef{noptr-new-declarator}\br
\terminal{[} expression \terminal{]} \opt{attribute-specifier-seq}\br
\terminal{[} \opt{expression} \terminal{]} \opt{attribute-specifier-seq}\br
noptr-new-declarator \terminal{[} constant-expression \terminal{]} \opt{attribute-specifier-seq}
\end{bnf}

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

\pnum
If the \grammarterm{type-id} or \grammarterm{new-type-id}
denotes an array type of unknown bound\iref{dcl.array},
the \grammarterm{new-initializer} shall not be omitted;
the allocated object is an array with \tcode{n} elements,
where \tcode{n} is determined from the number of initial elements
supplied in
the \grammarterm{new-initializer}~(\ref{dcl.init.aggr}, \ref{dcl.init.string}).

\pnum
\indextext{\idxcode{new}}%
If the \grammarterm{expression} in a \grammarterm{noptr-new-declarator}
is present, it is implicitly converted to \tcode{std::size_t}.
\indextext{function!allocation}%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this index should precede the new text?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's existing stuff, and I'm not too happy about the indexing here in general. I'd like to leave it as-is for now.

The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is
erroneous if:
The \grammarterm{expression} is erroneous if:

\begin{itemize}
\item
Expand Down