From 8cff053e05a4d18c6c267aaec081493b767d5458 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 15 Nov 2020 07:26:41 -0800 Subject: [PATCH 1/6] CWG2312 Structured bindings and mutable --- source/declarations.tex | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index 8ed3e07da3..a068b112de 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -6581,7 +6581,7 @@ that is a function template whose first template parameter is a non-type parameter, the initializer is -\tcode{\exposid{e}.get()}. Otherwise, the initializer is \tcode{get(\exposid{e})}, +\tcode{\exposidnc{e}.get()}. Otherwise, the initializer is \tcode{get(\exposid{e})}, where \tcode{get} is looked up in the associated namespaces\iref{basic.lookup.argdep}. In either case, \tcode{get} is interpreted as a \grammarterm{template-id}. \begin{note} @@ -6610,7 +6610,7 @@ all of \tcode{E}'s non-static data members shall be direct members of \tcode{E} or of the same base class of \tcode{E}, -well-formed when named as \tcode{\exposid{e}.\placeholder{name}} +well-formed when named as \tcode{\exposidnc{e}.\placeholder{name}} in the context of the structured binding, \tcode{E} shall not have an anonymous union member, and the number of elements in the \grammarterm{identifier-list} shall be @@ -6620,16 +6620,20 @@ (in declaration order), each \tcode{v}$_i$ is the name of an lvalue that refers to the member \tcode{m}$_i$ of \exposid{e} and -whose type is \cv{}~$\tcode{T}_i$, where $\tcode{T}_i$ is the declared type of -that member; the referenced type is \cv{}~$\tcode{T}_i$. The lvalue is a +whose type is +that of \tcode{\exposidnc{e}.$\tcode{m}_i$}\iref{expr.ref}; +the referenced type is +the declared type of $\tcode{m}_i$ if that type is a reference type, or +the type of \tcode{\exposidnc{e}.$\tcode{m}_i$} otherwise. +The lvalue is a bit-field if that member is a bit-field. \begin{example} \begin{codeblock} -struct S { int x1 : 2; volatile double y1; }; +struct S { mutable int x1 : 2; volatile double y1; }; S f(); const auto [ x, y ] = f(); \end{codeblock} -The type of the \grammarterm{id-expression} \tcode{x} is ``\tcode{const int}'', +The type of the \grammarterm{id-expression} \tcode{x} is ``\tcode{int}'', the type of the \grammarterm{id-expression} \tcode{y} is ``\tcode{const volatile double}''. \end{example} From 7ee5245c9bc3ed8ec0a63195d53184bc014b6dd9 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 15 Nov 2020 07:47:54 -0800 Subject: [PATCH 2/6] CWG2369 Ordering between constraints and substitution --- source/templates.tex | 70 +++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/source/templates.tex b/source/templates.tex index b3615de5d6..86dd5c02b3 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -7596,13 +7596,52 @@ When all template arguments have been deduced or obtained from default template arguments, all uses of template parameters in -the template parameter list of the template and the function type +the template parameter list of the template are replaced with the corresponding deduced or default argument values. If the substitution results in an invalid type, as described above, type deduction fails. If the function template has associated constraints\iref{temp.constr.decl}, those constraints are checked for satisfaction\iref{temp.constr.constr}. If the constraints are not satisfied, type deduction fails. +In the context of a function call, if type deduction has not yet failed, then +for those function parameters for which the function call has arguments, +each function parameter with a type that was non-dependent +before substitution of any explicitly-specified template arguments +is checked against its corresponding argument; +if the corresponding argument cannot be implicitly converted +to the parameter type, type deduction fails. +\begin{note} +Overload resolution will check the other parameters, including +parameters with dependent types in which +no template parameters participate in template argument deduction and +parameters that became non-dependent due to substitution of +explicitly-specified template arguments. +\end{note} +If type deduction has not yet failed, then +all uses of template parameters in the function type are +replaced with the corresponding deduced or default argument values. +If the substitution results in an invalid type, as described above, +type deduction fails. +\begin{example} +\begin{codeblock} +template struct Z { + typedef typename T::x xx; +}; +template concept C = requires { typename T::A; }; +template typename Z::xx f(void *, T); // \#1 +template void f(int, T); // \#2 +struct A {} a; +struct ZZ { + template ::xx> operator T *(); + operator int(); +}; +int main() { + ZZ zz; + f(1, a); // OK, deduction fails for \#1 because there is no conversion from \tcode{int} to \tcode{void*} + f(zz, 42); // OK, deduction fails for \#1 because \tcode{C} is not satisfied +} +\end{codeblock} +\end{example} \pnum At certain points in the template argument deduction process it is necessary @@ -8160,35 +8199,6 @@ \end{codeblock} \end{example} -\pnum -If deduction succeeds for all parameters that contain -\grammarterm{template-parameter}{s} that participate in template argument -deduction, and all template arguments are explicitly specified, deduced, -or obtained from default template arguments, remaining parameters are then -compared with the corresponding arguments. For each remaining parameter -\tcode{P} with a type that was non-dependent before substitution of any -explicitly-specified template arguments, if the corresponding argument -\tcode{A} cannot be implicitly converted to \tcode{P}, deduction fails. -\begin{note} -Parameters with dependent types in which no \grammarterm{template-parameter}{s} -participate in template argument deduction, and parameters that became -non-dependent due to substitution of explicitly-specified template arguments, -will be checked during overload resolution. -\end{note} -\begin{example} -\begin{codeblock} -template struct Z { - typedef typename T::x xx; -}; -template typename Z::xx f(void *, T); // \#1 -template void f(int, T); // \#2 -struct A {} a; -int main() { - f(1, a); // OK, deduction fails for \#1 because there is no conversion from \tcode{int} to \tcode{void*} -} -\end{codeblock} -\end{example} - \rSec3[temp.deduct.funcaddr]{Deducing template arguments taking the address of a function template} \pnum From ea75121c3ce6e32d714380ce3ef7c45045b6478c Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 15 Nov 2020 07:54:00 -0800 Subject: [PATCH 3/6] CWG2452 Flowing off the end of a coroutine --- source/statements.tex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/statements.tex b/source/statements.tex index c4268d81f1..020b256305 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -924,8 +924,10 @@ \pnum If \placeholder{p}\tcode{.return_void()} is a valid expression, -flowing off the end of a coroutine is equivalent to a \tcode{co_return} with no operand; -otherwise flowing off the end of a coroutine results in undefined behavior. +flowing off the end of a coroutine's \grammarterm{function-body} +is equivalent to a \tcode{co_return} with no operand; +otherwise flowing off the end of a coroutine's \grammarterm{function-body} +results in undefined behavior. \rSec2[stmt.goto]{The \tcode{goto} statement}% \indextext{statement!\idxcode{goto}} From cf43bddb0fc323ca7a2402d7094318c2b39e7fcf Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 15 Nov 2020 07:56:04 -0800 Subject: [PATCH 4/6] CWG2457 Unexpanded parameter packs don't make a function type dependent --- source/templates.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/templates.tex b/source/templates.tex index 86dd5c02b3..72e9d7f075 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -5349,6 +5349,8 @@ an array type whose element type is dependent or whose bound (if any) is value-dependent, \item +a function type whose parameters include one or more function parameter packs, +\item a function type whose exception specification is value-dependent, \item denoted by a \grammarterm{simple-template-id} From 472078f00670e42c1356d11cfe3a4b651c8357ab Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 15 Nov 2020 08:00:13 -0800 Subject: [PATCH 5/6] CWG2460 C language linkage and constrained non-template friends --- source/declarations.tex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index a068b112de..1e0534a75b 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -8313,8 +8313,9 @@ \indextext{class!linkage specification}% A C language linkage is ignored in determining the language linkage of -the names of class members and the -function type of class member functions. +the names of class members, +the names of friend functions with a trailing \grammarterm{requires-clause}, and +the function type of class member functions. \begin{example} \begin{codeblock} extern "C" typedef void FUNC_c(); From 6fe12071d6fb342ef1f39f4c659b324a65f073f5 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 15 Nov 2020 08:05:40 -0800 Subject: [PATCH 6/6] CWG2461 Diagnosing non-bool type constraints --- source/templates.tex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/templates.tex b/source/templates.tex index 72e9d7f075..0ed61850f7 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -4532,9 +4532,10 @@ or a substatement of a constexpr if statement\iref{stmt.if} within a template and the template is not instantiated, or \item -no substitution of template arguments -into a \grammarterm{type-constraint} or \grammarterm{requires-clause} -would result in a valid expression, or +any \grammarterm{constraint-expression} in the program, introduced or otherwise, +has (in its normal form) an atomic constraint $A$ where +no satisfaction check of $A$ could be well-formed and +no satisfaction check of $A$ is performed, or \item every valid specialization of a variadic template requires an empty template parameter pack, or