From 44d91596bf91ddbaada724ceda4d893a853dd444 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Tue, 5 Mar 2019 00:24:34 +0100 Subject: [PATCH 1/2] P1009R2 Array size deduction in new-expressions --- source/expressions.tex | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index f28dc349b9..9ebc4ae374 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -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} @@ -4548,8 +4548,8 @@ 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}. +If the \grammarterm{expression} in a \grammarterm{noptr-new-declarator} +is present, it 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 @@ -4558,6 +4558,15 @@ constant expression). \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{function!allocation}% The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is From c9074b533c835bbf820f5ea09957810ed2c04dab Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Wed, 6 Mar 2019 20:56:58 +0100 Subject: [PATCH 2/2] [expr.new] Move treatment of arrays of unknown bound --- source/expressions.tex | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index 9ebc4ae374..4e21d1c139 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -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}}% -If the \grammarterm{expression} in a \grammarterm{noptr-new-declarator} -is present, it 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 @@ -4568,9 +4565,11 @@ 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}% -The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is -erroneous if: +The \grammarterm{expression} is erroneous if: \begin{itemize} \item