Skip to content

Commit 6798cee

Browse files
authored
Merge 2023-02 CWG Motion 1
P2796R0 Core Language Working Group "ready" issues for the February, 2023 meeting; excluding issues 2518, 2521, 2659, 2674, 2678, and 2691
2 parents 9ce105b + 3225669 commit 6798cee

File tree

9 files changed

+192
-91
lines changed

9 files changed

+192
-91
lines changed

source/basic.tex

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,10 +1083,12 @@
10831083
The locus of a \grammarterm{class-specifier} is immediately after
10841084
the \grammarterm{identifier} or \grammarterm{simple-template-id} (if any)
10851085
in its \grammarterm{class-head}\iref{class.pre}.
1086-
The locus of
1087-
an \grammarterm{enum-specifier} or \grammarterm{opaque-enum-declaration}
1088-
is immediately after the \grammarterm{identifier} (if any)
1089-
in it\iref{dcl.enum}.
1086+
The locus of an \grammarterm{enum-specifier}
1087+
is immediately after
1088+
its \grammarterm{enum-head};
1089+
the locus of an \grammarterm{opaque-enum-declaration}
1090+
is immediately after it\iref{dcl.enum}.
1091+
%FIXME: What's "it" below? What's "it" above?
10901092
The locus of an \grammarterm{alias-declaration} is immediately after it.
10911093

10921094
\pnum
@@ -1512,18 +1514,18 @@
15121514

15131515
\pnum
15141516
\indextext{scope!search}%
1515-
A \defn{search} in a scope $X$ for a name $N$ from a program point $P$
1516-
is a single search in $X$ for $N$ from $P$
1517+
A \defn{search} in a scope $X$ for a name $M$ from a program point $P$
1518+
is a single search in $X$ for $M$ from $P$
15171519
unless $X$ is the scope of a class or class template $T$, in which case the
15181520
following steps define the result of the search.
15191521
\begin{note}
15201522
The result differs only
1521-
if $N$ is a \grammarterm{conversion-function-id} or
1523+
if $M$ is a \grammarterm{conversion-function-id} or
15221524
if the single search would find nothing.
15231525
\end{note}
15241526

15251527
\pnum
1526-
The \defn{lookup set} for $N$ in $C$, called $S(N,C)$,
1528+
The \defn{lookup set} for a name $N$ in a class or class template $C$, called $S(N,C)$,
15271529
consists of two component sets:
15281530
the \term{declaration set}, a set of members named $N$; and
15291531
the \term{subobject set},
@@ -1548,10 +1550,10 @@
15481550
in each direct non-dependent\iref{temp.dep.type} base class subobject $B_i$, and
15491551
merge each such lookup set $S(N,B_i)$ in turn into $S(N,C)$.
15501552
\begin{note}
1551-
If $T$ is incomplete,
1553+
If $C$ is incomplete,
15521554
only base classes whose \grammarterm{base-specifier} appears before $P$
15531555
are considered.
1554-
If $T$ is an instantiated class, its base classes are not dependent.
1556+
If $C$ is an instantiated class, its base classes are not dependent.
15551557
\end{note}
15561558

15571559
\pnum
@@ -1577,9 +1579,9 @@
15771579
\end{itemize}
15781580

15791581
\pnum
1580-
The result of the search is the declaration set of $S(N,T)$.
1582+
The result of the search is the declaration set of $S(M,T)$.
15811583
If it is an invalid set, the program is ill-formed.
1582-
If it differs from the result of a search in $T$ for $N$
1584+
If it differs from the result of a search in $T$ for $M$
15831585
in a complete-class context\iref{class.mem} of $T$,
15841586
the program is ill-formed, no diagnostic required.
15851587
\begin{example}
@@ -1602,7 +1604,7 @@
16021604
\end{example}
16031605

16041606
\pnum
1605-
If $N$ is a non-dependent \grammarterm{conversion-function-id},
1607+
If $M$ is a non-dependent \grammarterm{conversion-function-id},
16061608
conversion function templates that are members of $T$ are considered.
16071609
For each such template $F$, the lookup set $S(t,T)$ is constructed,
16081610
considering a function template declaration to have the name $t$
@@ -3329,7 +3331,7 @@
33293331

33303332
\pnum
33313333
An operation that begins the lifetime of
3332-
an array of \tcode{char}, \tcode{unsigned char}, or \tcode{std::byte}
3334+
an array of \tcode{unsigned char} or \tcode{std::byte}
33333335
implicitly creates objects within the region of storage occupied by the array.
33343336
\begin{note}
33353337
The array object provides storage for these objects.
@@ -3407,8 +3409,11 @@
34073409
A \grammarterm{delete-expression}\iref{expr.delete} invokes the destructor
34083410
prior to releasing the storage.
34093411
\end{note}
3410-
In this case, the destructor is not implicitly invoked and any program that
3411-
depends on the side effects produced by the destructor has undefined behavior.
3412+
In this case, the destructor is not implicitly invoked.
3413+
\begin{note}
3414+
The correct behavior of a program often depends on
3415+
the destructor being invoked for each object of class type.
3416+
\end{note}
34123417

34133418
\pnum
34143419
Before the lifetime of an object has started but after the storage which

source/classes.tex

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@
19441944
\end{example}
19451945

19461946
\pnum
1947-
The implicitly-defined copy assignment operator for a
1947+
The implicitly-defined copy/move assignment operator for a
19481948
union \tcode{X} copies the object representation\iref{term.object.representation} of \tcode{X}.
19491949
If the source and destination of the assignment are not the same object, then
19501950
for each object nested within\iref{intro.object}
@@ -2095,7 +2095,7 @@
20952095

20962096
\pnum
20972097
A defaulted destructor is a constexpr destructor
2098-
if it satisfies the requirements for a constexpr function\iref{dcl.constexpr}.
2098+
if it is constexpr-suitable\iref{dcl.constexpr}.
20992099

21002100
\pnum
21012101
Before a
@@ -4270,6 +4270,19 @@
42704270
access control is applied to it, not to the declarations that replace it.
42714271
For an overload set, access control is applied only to
42724272
the function selected by overload resolution.
4273+
\begin{example}
4274+
\begin{codeblock}
4275+
struct S {
4276+
void f(int);
4277+
private:
4278+
void f(double);
4279+
};
4280+
4281+
void g(S* sp) {
4282+
sp->f(2); // OK, access control applied after overload resolution
4283+
}
4284+
\end{codeblock}
4285+
\end{example}
42734286
\begin{note}
42744287
Because access control applies to the declarations named, if access control is applied to a
42754288
\grammarterm{typedef-name}, only the accessibility of the typedef or alias declaration itself is considered.
@@ -6542,7 +6555,8 @@
65426555

65436556
\begin{itemize}
65446557
\item
6545-
If \tcode{a <=> b} is usable\iref{class.compare.default},
6558+
If \tcode{a <=> b} is usable\iref{class.compare.default} and
6559+
can be explicitly converted to \tcode{R} using \keyword{static_cast},
65466560
\tcode{static_cast<R>(a <=> b)}.
65476561

65486562
\item

source/declarations.tex

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,28 @@
205205

206206
\pnum
207207
If the \grammarterm{decl-specifier-seq} contains the \keyword{typedef}
208-
specifier, the declaration is called a \defnx{typedef declaration}{declaration!typedef}
208+
specifier, the declaration is a \defnx{typedef declaration}{declaration!typedef}
209209
and each \grammarterm{declarator-id}
210210
is declared to be a \grammarterm{typedef-name}, synonymous with its
211211
associated type\iref{dcl.typedef}.
212212
\begin{note}
213213
Such a \grammarterm{declarator-id} is
214214
an \grammarterm{identifier}\iref{class.conv.fct}.
215215
\end{note}
216-
If the
217-
\grammarterm{decl-specifier-seq} contains no \keyword{typedef} specifier, the
218-
declaration is called a \defnx{function declaration}{declaration!function} if
219-
the type associated with a \grammarterm{declarator-id} is a function type\iref{dcl.fct} and
220-
an \defnx{object declaration}{declaration!object} otherwise.
216+
Otherwise, if the type associated with a \grammarterm{declarator-id}
217+
is a function type\iref{dcl.fct},
218+
the declaration is a \defnx{function declaration}{declaration!function}.
219+
Otherwise, if the type associated with a \grammarterm{declarator-id}
220+
is an object or reference type, the declaration is
221+
an \defnx{object declaration}{declaration!object}.
222+
Otherwise, the program is ill-formed.
223+
\begin{example}
224+
\begin{codeblock}
225+
int f(), x; // OK, function declaration for \tcode{f} and object declaration for \tcode{x}
226+
extern void g(), // OK, function declaration for \tcode{g}
227+
y; // error: \tcode{void} is not an object type
228+
\end{codeblock}
229+
\end{example}
221230

222231
\pnum
223232
\indextext{definition!declaration as}%
@@ -787,16 +796,17 @@
787796
\pnum
788797
\indextext{specifier!\idxcode{constexpr}!function}%
789798
\indextext{constexpr function}%
790-
The definition of a constexpr function shall satisfy the following
791-
requirements:
799+
A function is \defn{constexpr-suitable} if:
792800
\begin{itemize}
793801
\item
794-
it shall not be a coroutine\iref{dcl.fct.def.coroutine};
802+
it is not a coroutine\iref{dcl.fct.def.coroutine}, and
795803

796804
\item
797805
if the function is a constructor or destructor,
798-
its class shall not have any virtual base classes.
806+
its class does not have any virtual base classes.
799807
\end{itemize}
808+
Except for instantiated constexpr functions,
809+
non-templated constexpr functions shall be constexpr-suitable.
800810

801811
\begin{example}
802812
\begin{codeblock}
@@ -830,16 +840,6 @@
830840
\end{codeblock}
831841
\end{example}
832842

833-
\pnum
834-
If the instantiated template specialization of a constexpr function
835-
template
836-
or member function of a class template
837-
would fail to satisfy the requirements for a constexpr
838-
function,
839-
that specialization is still a constexpr function,
840-
even though a call to such a function cannot appear in a constant
841-
expression.
842-
843843
\pnum
844844
An invocation of a constexpr function in a given context
845845
produces the same result as
@@ -885,7 +885,9 @@
885885
In any \keyword{constexpr} variable declaration,
886886
the full-expression of the initialization
887887
shall be a constant expression\iref{expr.const}.
888-
A \keyword{constexpr} variable shall have constant destruction.
888+
A \keyword{constexpr} variable that is an object,
889+
as well as any temporary to which a \keyword{constexpr} reference is bound,
890+
shall have constant destruction.
889891
\begin{example}
890892
\begin{codeblock}
891893
struct pixel {
@@ -909,10 +911,12 @@
909911

910912
\pnum
911913
If a variable declared with the \keyword{constinit} specifier has
912-
dynamic initialization\iref{basic.start.dynamic}, the program is ill-formed.
914+
dynamic initialization\iref{basic.start.dynamic}, the program is ill-formed,
915+
even if the implementation would perform that initialization as
916+
a static initialization\iref{basic.start.static}.
913917
\begin{note}
914918
The \keyword{constinit} specifier ensures that the variable
915-
is initialized during static initialization\iref{basic.start.static}.
919+
is initialized during static initialization.
916920
\end{note}
917921

918922
\pnum
@@ -1747,8 +1751,8 @@
17471751
\end{example}
17481752

17491753
\pnum
1750-
Return type deduction for a templated entity
1751-
that is a function or function template with a placeholder in its
1754+
Return type deduction for a templated
1755+
function with a placeholder in its
17521756
declared type occurs when the definition is instantiated even if the function
17531757
body contains a \tcode{return} statement with a non-type-dependent operand.
17541758
\begin{note}
@@ -6252,7 +6256,7 @@
62526256
A function explicitly defaulted on its first declaration
62536257
is implicitly inline\iref{dcl.inline},
62546258
and is implicitly constexpr\iref{dcl.constexpr}
6255-
if it satisfies the requirements for a constexpr function.
6259+
if it is constexpr-suitable.
62566260

62576261
\pnum
62586262
\begin{example}
@@ -6968,6 +6972,8 @@
69686972
not omit the \grammarterm{enum-base}.
69696973
The identifiers in an \grammarterm{enumerator-list} are declared as
69706974
constants, and can appear wherever constants are required.
6975+
The same identifier shall not appear as
6976+
the name of multiple enumerators in an \grammarterm{enumerator-list}.
69716977
\indextext{enumerator!value of}%
69726978
An \grammarterm{enumerator-definition} with \tcode{=} gives the associated
69736979
\grammarterm{enumerator} the value indicated by the
@@ -8251,7 +8257,7 @@
82518257
in determining the language linkage of
82528258
class members,
82538259
friend functions with a trailing \grammarterm{requires-clause}, and the
8254-
function type of class member functions.
8260+
function type of non-static class member functions.
82558261
\begin{example}
82568262
\begin{codeblock}
82578263
extern "C" typedef void FUNC_c();
@@ -8505,6 +8511,17 @@
85058511
the rules specifying to which entity or statement the attribute can apply or
85068512
the syntax rules for the attribute's \grammarterm{attribute-argument-clause}, if any.
85078513
\end{note}
8514+
\begin{note}
8515+
The \grammarterm{attribute}{s} specified in \ref{dcl.attr}
8516+
have optional semantics:
8517+
given a well-formed program,
8518+
removing all instances of any one of those \grammarterm{attribute}{s}
8519+
results in a program whose set of possible executions\iref{intro.abstract}
8520+
for a given input is
8521+
a subset of those of the original program for the same input,
8522+
absent implementation-defined guarantees
8523+
with respect to that \grammarterm{attribute}.
8524+
\end{note}
85088525
An \grammarterm{attribute-token} is reserved for future standardization if
85098526
\begin{itemize}
85108527
\item it is not an \grammarterm{attribute-scoped-token} and

0 commit comments

Comments
 (0)