From 6181a4eca8fa097ba1367703b7c4a0111fbc49df Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 19:19:55 -0800 Subject: [PATCH 01/28] CWG2072 Default argument instantiation for member functions of templates --- source/templates.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/templates.tex b/source/templates.tex index c726e771ff..29ba182eaa 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -5991,7 +5991,7 @@ causes specializations in the default member initializer to be instantiated. \pnum -If a function template +If a templated function \tcode{f} is called in a way that requires a default argument to be used, the dependent names are looked up, the semantics constraints are checked, From 4682d959dff605c86b6ad361acccf839d2f0ccd2 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 19:42:26 -0800 Subject: [PATCH 02/28] CWG2475 Object declarations of type cv void --- source/declarations.tex | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index a63c317a72..40130833b1 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -205,7 +205,7 @@ \pnum If the \grammarterm{decl-specifier-seq} contains the \keyword{typedef} -specifier, the declaration is called a \defnx{typedef declaration}{declaration!typedef} +specifier, the declaration is a \defnx{typedef declaration}{declaration!typedef} and each \grammarterm{declarator-id} is declared to be a \grammarterm{typedef-name}, synonymous with its associated type\iref{dcl.typedef}. @@ -213,11 +213,20 @@ Such a \grammarterm{declarator-id} is an \grammarterm{identifier}\iref{class.conv.fct}. \end{note} -If the -\grammarterm{decl-specifier-seq} contains no \keyword{typedef} specifier, the -declaration is called a \defnx{function declaration}{declaration!function} if -the type associated with a \grammarterm{declarator-id} is a function type\iref{dcl.fct} and -an \defnx{object declaration}{declaration!object} otherwise. +Otherwise, if the type associated with a \grammarterm{declarator-id} +is a function type\iref{dcl.fct}, +the declaration is a \defnx{function declaration}{declaration!function}. +Otherwise, if the type associated with a \grammarterm{declarator-id} +is an object or reference type, the declaration is +an \defnx{object declaration}{declaration!object}. +Otherwise, the program is ill-formed. +\begin{example} +\begin{codeblock} +int f(), x; // OK, function declaration for \tcode{f} and object declaration for \tcode{x} +extern void g(), // OK, function declaration for \tcode{g} + y; // error: \tcode{void} is not an object type +\end{codeblock} +\end{example} \pnum \indextext{definition!declaration as}% From de45c7c6a88ca712eeb1d281827873878e4a385f Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 19:45:33 -0800 Subject: [PATCH 03/28] CWG2478 Properties of explicit specializations of implicitly-instantiated class templates --- source/templates.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/templates.tex b/source/templates.tex index 29ba182eaa..bc3fdf34a0 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -6604,7 +6604,7 @@ \pnum Whether an explicit specialization of a function or variable template -is inline, constexpr, or an immediate function +is inline, constexpr, constinit, or consteval is determined by the explicit specialization and is independent of those properties of the template. Similarly, From da1e3f9e441365edf3337068008a6c4db52711f7 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 20:00:33 -0800 Subject: [PATCH 04/28] CWG2483 Language linkage of static member functions --- source/declarations.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/declarations.tex b/source/declarations.tex index 40130833b1..5f8cd44bda 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -8260,7 +8260,7 @@ in determining the language linkage of class members, friend functions with a trailing \grammarterm{requires-clause}, and the -function type of class member functions. +function type of non-static class member functions. \begin{example} \begin{codeblock} extern "C" typedef void FUNC_c(); From 040d3c9f1509285b3244fe53d3e0fbff7350652d Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 20:02:38 -0800 Subject: [PATCH 05/28] CWG2489 Storage provided by array of char --- source/basic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/basic.tex b/source/basic.tex index bd155ed606..7ac04a277b 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -3329,7 +3329,7 @@ \pnum An operation that begins the lifetime of -an array of \tcode{char}, \tcode{unsigned char}, or \tcode{std::byte} +an array of \tcode{unsigned char} or \tcode{std::byte} implicitly creates objects within the region of storage occupied by the array. \begin{note} The array object provides storage for these objects. From 0b10921b8ee54b5a7837c97d6ac2afcb5e1c71c4 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 20:22:21 -0800 Subject: [PATCH 06/28] CWG2516 Locus of enum-specifier or opaque-enum-declaration --- source/basic.tex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/basic.tex b/source/basic.tex index 7ac04a277b..7b9c31cc1d 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -1083,10 +1083,12 @@ The locus of a \grammarterm{class-specifier} is immediately after the \grammarterm{identifier} or \grammarterm{simple-template-id} (if any) in its \grammarterm{class-head}\iref{class.pre}. -The locus of -an \grammarterm{enum-specifier} or \grammarterm{opaque-enum-declaration} -is immediately after the \grammarterm{identifier} (if any) -in it\iref{dcl.enum}. +The locus of an \grammarterm{enum-specifier} +is immediately after +its \grammarterm{enum-head}; +the locus of an \grammarterm{opaque-enum-declaration} +is immediately after it\iref{dcl.enum}. +%FIXME: What's "it" below? What's "it" above? The locus of an \grammarterm{alias-declaration} is immediately after it. \pnum From 7a947d7b2d374bdb2e59083918a24f219d64641e Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sat, 11 Feb 2023 20:24:50 -0800 Subject: [PATCH 07/28] CWG2517 Useless restriction on use of parameter in constraint-expression --- source/expressions.tex | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index 67edaeebf1..71c9de48db 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -3055,18 +3055,6 @@ \end{codeblock} \tcode{D} is satisfied if \tcode{sizeof(decltype (+t)) == 1}\iref{temp.constr.atomic}. \end{example} - -\pnum -A local parameter shall only appear as an unevaluated operand\iref{term.unevaluated.operand} -within the \grammarterm{constraint-expression}. -\begin{example} -\begin{codeblock} -template concept C = requires (T a) { - requires sizeof(a) == 4; // OK - requires a == 0; // error: evaluation of a constraint variable -}; -\end{codeblock} -\end{example} \indextext{expression!requires|)} \indextext{expression!primary|)} From 8af88f7b7a97aed1199ba6b13d9cf6e796ba76d5 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Sun, 12 Feb 2023 00:32:40 -0800 Subject: [PATCH 08/28] CWG2520 Template signature and default template arguments --- source/intro.tex | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/intro.tex b/source/intro.tex index e14bda23af..56ab3039f2 100644 --- a/source/intro.tex +++ b/source/intro.tex @@ -600,7 +600,7 @@ parameter-type-list, enclosing namespace, return type, -\grammarterm{template-head}, +signature of the \grammarterm{template-head}, and trailing \grammarterm{requires-clause} (if any) @@ -611,7 +611,7 @@ parameter-type-list, return type, enclosing class, -\grammarterm{template-head}, +signature of the \grammarterm{template-head}, and trailing \grammarterm{requires-clause} (if any) @@ -640,7 +640,7 @@ \cv-qualifiers (if any), \grammarterm{ref-qualifier} (if any), return type (if any), -\grammarterm{template-head}, +signature of the \grammarterm{template-head}, and trailing \grammarterm{requires-clause} (if any) @@ -649,6 +649,14 @@ \defncontext{class member function template specialization} signature of the member function template of which it is a specialization and its template arguments (whether explicitly specified or deduced) +\indexdefn{signature}% +\definition{signature}{defns.signature.template.head} +\defncontext{\grammarterm{template-head}} +template parameter list, +excluding template parameter names and default arguments, +and +\grammarterm{requires-clause} (if any) + \definition{stable algorithm}{defns.stable} \defncontext{library} \indexdefn{algorithm!stable}% From c7558149d75b95e49faa60ab771a65da08fe2d20 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 15:39:45 -0800 Subject: [PATCH 09/28] CWG2523 Undefined behavior via omitted destructor call in constant expressions --- source/basic.tex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/basic.tex b/source/basic.tex index 7b9c31cc1d..263f354ada 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -3409,8 +3409,11 @@ A \grammarterm{delete-expression}\iref{expr.delete} invokes the destructor prior to releasing the storage. \end{note} -In this case, the destructor is not implicitly invoked and any program that -depends on the side effects produced by the destructor has undefined behavior. +In this case, the destructor is not implicitly invoked. +\begin{note} +The correct behavior of a program often depends on +the destructor being invoked for each object of class type. +\end{note} \pnum Before the lifetime of an object has started but after the storage which From 43cb1a48739216ce944a03fb2a4e32f29b140eb1 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 15:53:45 -0800 Subject: [PATCH 10/28] CWG2526 Relational comparison of void* pointers --- source/expressions.tex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/expressions.tex b/source/expressions.tex index 71c9de48db..f7df42bac9 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -6543,6 +6543,11 @@ \tcode{q<=p}, and \tcode{q=p}, and \tcode{q>p} all yield \keyword{false}. Otherwise, the result of each of the operators is unspecified. +\begin{note} +A relational operator applied +to unequal function pointers or to unequal pointers to \tcode{void} +yields an unspecified result. +\end{note} \pnum If both operands (after conversions) are of arithmetic or enumeration type, each From f4285247cb9ee54d6b3fe81f0fe680186075d42b Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:19:41 -0800 Subject: [PATCH 11/28] CWG2528 Three-way comparison and the usual arithmetic conversions --- source/expressions.tex | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index f7df42bac9..498c3222d1 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -1142,38 +1142,34 @@ \item Otherwise, the expression is ill-formed. \end{itemize} -\item Otherwise, the integral promotions\iref{conv.prom} are -performed on both operands. +\item Otherwise, each operand is converted to a common type \tcode{C}. +The integral promotion rules\iref{conv.prom} are used +to determine a type \tcode{T1} and type \tcode{T2} for each operand. \begin{footnote} As a consequence, operands of type \keyword{bool}, \keyword{char8_t}, \keyword{char16_t}, \keyword{char32_t}, \keyword{wchar_t}, or of enumeration type are converted to some integral type. \end{footnote} -Then the following rules are applied to the promoted operands: +Then the following rules are applied to determine \tcode{C}: \begin{itemize} -\item If both operands have the same type, no further conversion is -needed. +\item If \tcode{T1} and \tcode{T2} are the same type, \tcode{C} is that type. -\item Otherwise, if both operands have signed integer types or both have -unsigned integer types, the operand with the type of lesser integer -conversion rank is converted to the type of the operand with -greater rank. +\item Otherwise, if \tcode{T1} and \tcode{T2} are both signed integer types or +are both unsigned integer types, +\tcode{C} is the type with greater rank. -\item Otherwise, if the operand that has unsigned integer type has rank -greater than or equal to the rank of the type of the other operand, the -operand with signed integer type is converted to the type of the -operand with unsigned integer type. - -\item Otherwise, if the type of the operand with signed integer type can -represent all of the values of the type of the operand with unsigned -integer type, the operand with unsigned integer type is converted -to the type of the operand with signed integer type. - -\item Otherwise, both operands are converted to the unsigned -integer type corresponding to the type of the operand with signed -integer type. +\item Otherwise, let \tcode{U} be the unsigned integer type and +\tcode{S} be the signed integer type. +\begin{itemize} +\item If \tcode{U} has rank greater than or equal to the rank of \tcode{S}, +\tcode{C} is \tcode{U}. +\item Otherwise, if \tcode{S} can represent all of the values of \tcode{U}, +\tcode{C} is \tcode{S}. +\item Otherwise, +\tcode{C} is the unsigned integer type corresponding to \tcode{S}. +\end{itemize} \end{itemize} \end{itemize} From 68330dc390df8aefe1d51b6737e87a030919ccb1 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:28:07 -0800 Subject: [PATCH 12/28] CWG2529 Constant destruction of constexpr references --- source/declarations.tex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/declarations.tex b/source/declarations.tex index 5f8cd44bda..72f1ab9192 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -894,7 +894,9 @@ In any \keyword{constexpr} variable declaration, the full-expression of the initialization shall be a constant expression\iref{expr.const}. -A \keyword{constexpr} variable shall have constant destruction. +A \keyword{constexpr} variable that is an object, +as well as any temporary to which a \keyword{constexpr} reference is bound, +shall have constant destruction. \begin{example} \begin{codeblock} struct pixel { From 9859f3b378464ad21bfb640366cf0610a5def9bc Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:32:31 -0800 Subject: [PATCH 13/28] CWG2530 Multiple definitions of enumerators --- source/declarations.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/declarations.tex b/source/declarations.tex index 72f1ab9192..b704cdd0ea 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -6979,6 +6979,8 @@ not omit the \grammarterm{enum-base}. The identifiers in an \grammarterm{enumerator-list} are declared as constants, and can appear wherever constants are required. +The same identifier shall not appear as +the name of multiple enumerators in an \grammarterm{enumerator-list}. \indextext{enumerator!value of}% An \grammarterm{enumerator-definition} with \tcode{=} gives the associated \grammarterm{enumerator} the value indicated by the From 60430bbc556ba2db172d5927ae299c7b7db78020 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:36:33 -0800 Subject: [PATCH 14/28] CWG2539 Three-way comparison requiring strong ordering for floating-point types --- source/classes.tex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/classes.tex b/source/classes.tex index e13097d465..91061946ff 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -6542,7 +6542,8 @@ \begin{itemize} \item -If \tcode{a <=> b} is usable\iref{class.compare.default}, +If \tcode{a <=> b} is usable\iref{class.compare.default} and +can be explicitly converted to \tcode{R} using \keyword{static_cast}, \tcode{static_cast(a <=> b)}. \item From 84ebbf7747a7721b6ea23825857d37e6c676ac4e Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:38:55 -0800 Subject: [PATCH 15/28] CWG2543 constinit and optimized dynamic initialization --- source/declarations.tex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index b704cdd0ea..601332a6c8 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -920,10 +920,12 @@ \pnum If a variable declared with the \keyword{constinit} specifier has -dynamic initialization\iref{basic.start.dynamic}, the program is ill-formed. +dynamic initialization\iref{basic.start.dynamic}, the program is ill-formed, +even if the implementation would perform that initialization as +a static initialization\iref{basic.start.static}. \begin{note} The \keyword{constinit} specifier ensures that the variable -is initialized during static initialization\iref{basic.start.static}. +is initialized during static initialization. \end{note} \pnum From 34ac2f42468156e1f2d8ec1cae196ad07c0077e4 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:43:35 -0800 Subject: [PATCH 16/28] CWG2558 Uninitialized subobjects as a result of an immediate invocation --- source/expressions.tex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/expressions.tex b/source/expressions.tex index 498c3222d1..4e076bea15 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -7774,6 +7774,11 @@ if the value is an object of class type, each non-static data member of reference type refers to an entity that is a permitted result of a constant expression, + + \item + if the value is an object of scalar type, + it does not have an indeterminate value\iref{basic.indet}, + \item if the value is of pointer type, it contains the address of an object with static storage duration, From ce7d8b0360e1509de6f7fd073d0a091238b1326f Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 16:54:54 -0800 Subject: [PATCH 17/28] CWG2602 consteval defaulted functions --- source/classes.tex | 2 +- source/declarations.tex | 21 ++++++--------------- source/expressions.tex | 5 ++--- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/source/classes.tex b/source/classes.tex index 91061946ff..d040c80524 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -2095,7 +2095,7 @@ \pnum A defaulted destructor is a constexpr destructor -if it satisfies the requirements for a constexpr function\iref{dcl.constexpr}. +if it is constexpr-suitable\iref{dcl.constexpr}. \pnum Before a diff --git a/source/declarations.tex b/source/declarations.tex index 601332a6c8..0b39e682e1 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -796,16 +796,17 @@ \pnum \indextext{specifier!\idxcode{constexpr}!function}% \indextext{constexpr function}% -The definition of a constexpr function shall satisfy the following -requirements: +A function is \defn{constexpr-suitable} if: \begin{itemize} \item -it shall not be a coroutine\iref{dcl.fct.def.coroutine}; +it is not a coroutine\iref{dcl.fct.def.coroutine}, and \item if the function is a constructor or destructor, -its class shall not have any virtual base classes. +its class does not have any virtual base classes. \end{itemize} +Except for instantiated constexpr functions, +non-templated constexpr functions shall be constexpr-suitable. \begin{example} \begin{codeblock} @@ -839,16 +840,6 @@ \end{codeblock} \end{example} -\pnum -If the instantiated template specialization of a constexpr function -template -or member function of a class template -would fail to satisfy the requirements for a constexpr -function, -that specialization is still a constexpr function, -even though a call to such a function cannot appear in a constant -expression. - \pnum An invocation of a constexpr function in a given context produces the same result as @@ -6265,7 +6256,7 @@ A function explicitly defaulted on its first declaration is implicitly inline\iref{dcl.inline}, and is implicitly constexpr\iref{dcl.constexpr} -if it satisfies the requirements for a constexpr function. +if it is constexpr-suitable. \pnum \begin{example} diff --git a/source/expressions.tex b/source/expressions.tex index 4e076bea15..0051559e3f 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -1961,7 +1961,7 @@ the corresponding \grammarterm{lambda-expression}{'s} \grammarterm{parameter-declaration-clause} is followed by \keyword{constexpr} or \keyword{consteval}, or -it satisfies the requirements for a constexpr function\iref{dcl.constexpr}. +it is constexpr-suitable\iref{dcl.constexpr}. It is an immediate function\iref{dcl.constexpr} if the corresponding \grammarterm{lambda-expression}{'s} \grammarterm{parameter-declaration-clause} is followed by \keyword{consteval}. @@ -7379,8 +7379,7 @@ \item an invocation of an instantiated constexpr function -that fails to satisfy the requirements -for a constexpr function; +that is not constexpr-suitable; \item an invocation of a virtual function\iref{class.virtual} From 4539636edeced42232613a9b3d9c2fab5f5a32a7 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:01:18 -0800 Subject: [PATCH 18/28] CWG2642 Inconsistent use of T and C --- source/basic.tex | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/basic.tex b/source/basic.tex index 263f354ada..5b47441bf3 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -1514,18 +1514,18 @@ \pnum \indextext{scope!search}% -A \defn{search} in a scope $X$ for a name $N$ from a program point $P$ -is a single search in $X$ for $N$ from $P$ +A \defn{search} in a scope $X$ for a name $M$ from a program point $P$ +is a single search in $X$ for $M$ from $P$ unless $X$ is the scope of a class or class template $T$, in which case the following steps define the result of the search. \begin{note} The result differs only -if $N$ is a \grammarterm{conversion-function-id} or +if $M$ is a \grammarterm{conversion-function-id} or if the single search would find nothing. \end{note} \pnum -The \defn{lookup set} for $N$ in $C$, called $S(N,C)$, +The \defn{lookup set} for a name $N$ in a class or class template $C$, called $S(N,C)$, consists of two component sets: the \term{declaration set}, a set of members named $N$; and the \term{subobject set}, @@ -1550,10 +1550,10 @@ in each direct non-dependent\iref{temp.dep.type} base class subobject $B_i$, and merge each such lookup set $S(N,B_i)$ in turn into $S(N,C)$. \begin{note} -If $T$ is incomplete, +If $C$ is incomplete, only base classes whose \grammarterm{base-specifier} appears before $P$ are considered. -If $T$ is an instantiated class, its base classes are not dependent. +If $C$ is an instantiated class, its base classes are not dependent. \end{note} \pnum @@ -1579,9 +1579,9 @@ \end{itemize} \pnum -The result of the search is the declaration set of $S(N,T)$. +The result of the search is the declaration set of $S(M,T)$. If it is an invalid set, the program is ill-formed. -If it differs from the result of a search in $T$ for $N$ +If it differs from the result of a search in $T$ for $M$ in a complete-class context\iref{class.mem} of $T$, the program is ill-formed, no diagnostic required. \begin{example} @@ -1604,7 +1604,7 @@ \end{example} \pnum -If $N$ is a non-dependent \grammarterm{conversion-function-id}, +If $M$ is a non-dependent \grammarterm{conversion-function-id}, conversion function templates that are members of $T$ are considered. For each such template $F$, the lookup set $S(t,T)$ is constructed, considering a function template declaration to have the name $t$ From e326276a2c2786edaa4cea31ee2723f39b3ce938 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:08:17 -0800 Subject: [PATCH 19/28] CWG2658 Trivial copying of unions in core constant expressions --- source/expressions.tex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/expressions.tex b/source/expressions.tex index 0051559e3f..24ca008a05 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -7616,6 +7616,15 @@ to storage allocated with \tcode{std::allocator} or to an object whose lifetime began within the evaluation of $E$. +\pnum +For the purposes of determining whether $E$ is a core constant expression, +the evaluation of a call to +a trivial copy/move constructor or copy/move assignment operator of a union +is considered to copy/move the active member of the union, if any. +\begin{note} +The copy/move of the active member is trivial. +\end{note} + \pnum During the evaluation of an expression $E$ as a core constant expression, all \grammarterm{id-expression}s and uses of \tcode{*\keyword{this}} From a78f64483e613afbb69ca7c3771f1c41472a34bb Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:13:02 -0800 Subject: [PATCH 20/28] CWG2662 Example for member access control vs. overload resolution --- source/classes.tex | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/classes.tex b/source/classes.tex index d040c80524..b179c0b66f 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -4270,6 +4270,19 @@ access control is applied to it, not to the declarations that replace it. For an overload set, access control is applied only to the function selected by overload resolution. +\begin{example} +\begin{codeblock} +struct S { + void f(int); +private: + void f(double); +}; + +void g(S* sp) { + sp->f(2); // OK, access control applied after overload resolution +} +\end{codeblock} +\end{example} \begin{note} Because access control applies to the declarations named, if access control is applied to a \grammarterm{typedef-name}, only the accessibility of the typedef or alias declaration itself is considered. From dbfffccc77a541af84d713785a7848428228215d Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:15:37 -0800 Subject: [PATCH 21/28] CWG2664 Deduction failure in CTAD for alias templates --- source/overloading.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/overloading.tex b/source/overloading.tex index cf0568fbb0..8aabf474a5 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -1351,6 +1351,8 @@ according to the process in \ref{temp.deduct.type} with the exception that deduction does not fail if not all template arguments are deduced. +If deduction fails for another reason, +proceed with an empty set of deduced template arguments. Let \tcode{g} denote the result of substituting these deductions into \tcode{f}. If substitution succeeds, From d487dc7ebeda1e09a66adc2c4f4295c72d265c9c Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:33:43 -0800 Subject: [PATCH 22/28] CWG2667 Named module imports do not import macros --- source/modules.tex | 7 +++++++ source/preprocessor.tex | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/source/modules.tex b/source/modules.tex index 0a65f8c069..f38503d39e 100644 --- a/source/modules.tex +++ b/source/modules.tex @@ -512,6 +512,13 @@ \end{footnote} These rules can in turn lead to the importation of yet more translation units. +\begin{note} +Such indirect importation does not make macros available, +because a translation unit is +a sequence of tokens in translation phase 7\iref{lex.phases}. +Macros can be made available by directly importing header units +as described in \ref{cpp.import}. +\end{note} \pnum A module implementation unit shall not be exported. diff --git a/source/preprocessor.tex b/source/preprocessor.tex index d01c69babf..d7b1201e6e 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -929,6 +929,18 @@ int a = Y; // OK, active macro definitions \#2 and \#4 are valid redefinitions int c = Z; // error: active macro definitions \#3 and \#5 are not valid redefinitions of \tcode{Z} \end{codeblocktu} + +\begin{codeblocktu}{Module unit \tcode{f}} +export module f; +export import "a.h"; + +int a = Y; // OK +\end{codeblocktu} + +\begin{codeblocktu}{Translation unit \tcode{\#1}} +import f; +int x = Y; // error: \tcode{Y} is neither a defined macro nor a declared name +\end{codeblocktu} \end{example} \indextext{macro!import|)} From d470e419dddc42a89f2e1478535e66e258f0e318 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:35:38 -0800 Subject: [PATCH 23/28] CWG2673 User-declared spaceship vs. built-in operators --- source/overloading.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/source/overloading.tex b/source/overloading.tex index 8aabf474a5..6592718c09 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -723,6 +723,7 @@ operands can be converted according to \ref{over.best.ics}, and \item do not have the same parameter-type-list as any non-member candidate +or rewritten non-member candidate that is not a function template specialization. \end{itemize} From 8623a6a9ccf7da865c356971d6c7e967e6d5fe8b Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 17:47:14 -0800 Subject: [PATCH 24/28] CWG2681 Deducing member array type from string literal --- source/overloading.tex | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source/overloading.tex b/source/overloading.tex index 6592718c09..2fa7e12bbd 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -1258,9 +1258,14 @@ \begin{itemize} \item if $e_i$ is of array type and -$x_i$ is a \grammarterm{braced-init-list} or \grammarterm{string-literal}, +$x_i$ is a \grammarterm{braced-init-list}, $\tcode{T}_i$ is an rvalue reference to the declared type of $e_i$, and \item +if $e_i$ is of array type and +$x_i$ is a \grammarterm{string-literal}, +$\tcode{T}_i$ is an lvalue reference to +the const-qualified declared type of $e_i$, and +\item otherwise, $\tcode{T}_i$ is the declared type of $e_i$, \end{itemize} except that additional parameter packs of the form $\tcode{P}_j \tcode{...}$ @@ -1330,6 +1335,23 @@ } G g(true, 'a', 1); // OK, deduces \tcode{G} + +template +struct H { + T array[N]; +}; +template +struct I { + volatile T array[N]; +}; +template +struct J { + unsigned char array[N]; +}; + +H h = { "abc" }; // OK, deduces \tcode{H} (not \tcode{T = const char}) +I i = { "def" }; // OK, deduces \tcode{I} +J j = { "ghi" }; // error: cannot bind reference to array of \tcode{unsigned char} to array of \tcode{char} in deduction \end{codeblock} \end{example} From 9fa6c9e80b655aa21b1cca414b0f4e879e44f392 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 19:11:18 -0800 Subject: [PATCH 25/28] CWG2682 Templated function vs. function template --- source/declarations.tex | 4 ++-- source/templates.tex | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index 0b39e682e1..d6cc84db01 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -1751,8 +1751,8 @@ \end{example} \pnum -Return type deduction for a templated entity -that is a function or function template with a placeholder in its +Return type deduction for a templated +function with a placeholder in its declared type occurs when the definition is instantiated even if the function body contains a \tcode{return} statement with a non-type-dependent operand. \begin{note} diff --git a/source/templates.tex b/source/templates.tex index bc3fdf34a0..d5d79e8b76 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -172,6 +172,13 @@ templated entity is a templated entity. \end{note} +A \defnadj{templated}{function} is +a function template or a function that is templated. +A \defnadj{templated}{class} is +a class template or a class that is templated. +A \defnadj{templated}{variable} is +a variable template or a variable that is templated. + \pnum A \grammarterm{template-declaration} is written in terms of its template parameters. From e2fb7e377b8678559ee2a2d85c75ed69a15e605a Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 19:21:24 -0800 Subject: [PATCH 26/28] CWG2685 Aggregate CTAD, string, and brace elision --- source/overloading.tex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/overloading.tex b/source/overloading.tex index 2fa7e12bbd..d09474051f 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -1241,8 +1241,12 @@ \begin{itemize} \item brace elision is not considered for any aggregate element -that has a dependent non-array type or -an array type with a value-dependent bound, and +that has +\begin{itemize} +\item a dependent non-array type, +\item an array type with a value-dependent bound, or +\item an array type with a dependent array element type and $x_i$ is a string literal; and +\end{itemize} \item each non-trailing aggregate element that is a pack expansion is assumed to correspond to no elements of the initializer list, and From 224f6baf3aa85ea3401f0ed97c0a8d3201e4a49b Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 19:22:49 -0800 Subject: [PATCH 27/28] CWG2690 Semantics of defaulted move assignment operator for unions --- source/classes.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/classes.tex b/source/classes.tex index b179c0b66f..1f2ea99c5e 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -1944,7 +1944,7 @@ \end{example} \pnum -The implicitly-defined copy assignment operator for a +The implicitly-defined copy/move assignment operator for a union \tcode{X} copies the object representation\iref{term.object.representation} of \tcode{X}. If the source and destination of the assignment are not the same object, then for each object nested within\iref{intro.object} From 32256699235714f16e7c44803348db309c6a550b Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 13 Feb 2023 19:33:45 -0800 Subject: [PATCH 28/28] CWG2695 Semantic ignorability of attributes --- source/declarations.tex | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/declarations.tex b/source/declarations.tex index d6cc84db01..9eceedcfb8 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -8511,6 +8511,17 @@ the rules specifying to which entity or statement the attribute can apply or the syntax rules for the attribute's \grammarterm{attribute-argument-clause}, if any. \end{note} +\begin{note} +The \grammarterm{attribute}{s} specified in \ref{dcl.attr} +have optional semantics: +given a well-formed program, +removing all instances of any one of those \grammarterm{attribute}{s} +results in a program whose set of possible executions\iref{intro.abstract} +for a given input is +a subset of those of the original program for the same input, +absent implementation-defined guarantees +with respect to that \grammarterm{attribute}. +\end{note} An \grammarterm{attribute-token} is reserved for future standardization if \begin{itemize} \item it is not an \grammarterm{attribute-scoped-token} and