Skip to content

Commit 37303be

Browse files
authored
Merge 2024-06 CWG Motion 1
P3345R0 Core Language Working Group "ready" Issues, all issues except 2819, 2858, and 2876 (and note that 2144 is subsumed by 2876)
2 parents b2870b5 + 8f43f8d commit 37303be

File tree

10 files changed

+279
-151
lines changed

10 files changed

+279
-151
lines changed

source/basic.tex

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,9 @@
511511
either:
512512
\begin{itemize}
513513
\item the intervening scope is a block scope, or
514-
\item the intervening scope is the function parameter scope of a \grammarterm{lambda-expression}
514+
\item the intervening scope is the function parameter scope of a \grammarterm{lambda-expression}, or
515+
\item the intervening scope is the lambda scope of
516+
a \grammarterm{lambda-expression}
515517
that has a \grammarterm{simple-capture}
516518
naming the entity or has a \grammarterm{capture-default}, and
517519
the block scope of the \grammarterm{lambda-expression}
@@ -2664,28 +2666,18 @@
26642666

26652667
\pnum
26662668
\indextext{translation unit}%
2667-
A name is said to have \defn{linkage} when it can denote the same
2668-
object, reference, function, type, template, namespace or value as a
2669-
name introduced by a declaration in another scope:
2670-
\begin{itemize}
2671-
\item When a name has \defnadj{external}{linkage},
2672-
the entity it denotes
2673-
can be referred to by names from scopes of other translation units or
2674-
from other scopes of the same translation unit.
2675-
2676-
\item When a name has \defnx{module linkage}{linkage!module},
2677-
the entity it denotes
2678-
can be referred to by names from other scopes of the same module unit\iref{module.unit} or
2679-
from scopes of other module units of that same module.
2680-
2681-
\item When a name has \defnadj{internal}{linkage},
2682-
the entity it denotes
2683-
can be referred to by names from other scopes in the same translation
2684-
unit.
2685-
2686-
\item When a name has \indextext{linkage!no}\defn{no linkage}, the entity it denotes
2687-
cannot be referred to by names from other scopes.
2688-
\end{itemize}
2669+
A name can have
2670+
\defnadj{external}{linkage},
2671+
\defnadj{module}{linkage},
2672+
\defnadj{internal}{linkage}, or
2673+
\defnadj{no}{linkage},
2674+
as determined by the rules below.
2675+
\begin{note}
2676+
All declarations of an entity with a name with internal linkage
2677+
appear in the same translation unit.
2678+
All declarations of an entity with module linkage
2679+
are attached to the same module.
2680+
\end{note}
26892681

26902682
\pnum
26912683
\indextext{linkage!\idxcode{static} and}%
@@ -2746,6 +2738,24 @@
27462738
has its linkage determined as follows:
27472739
\begin{itemize}
27482740
\item
2741+
\indextext{friend function!linkage of}%
2742+
if the entity is a function or function template
2743+
first declared in a friend declaration and
2744+
that declaration is a definition and
2745+
the enclosing class is defined within an \grammarterm{export-declaration},
2746+
the name has the same linkage, if any,
2747+
as the name of the enclosing class\iref{class.friend};
2748+
\item
2749+
otherwise,
2750+
\indextext{friend function!linkage of}%
2751+
if the entity is a function or function template
2752+
declared in a friend declaration and
2753+
a corresponding non-friend declaration is reachable,
2754+
%FIXME: Which declaration is "that prior declaration"?
2755+
%FIXME: "prior" with respect to what? And what about dependent lookup?
2756+
the name has the linkage determined from that prior declaration,
2757+
\item
2758+
otherwise,
27492759
if the enclosing namespace has internal linkage,
27502760
the name has internal linkage;
27512761
\item
@@ -3450,9 +3460,10 @@
34503460
The \defn{lifetime} of an object or reference is a runtime property of the
34513461
object or reference.
34523462
A variable is said to have \defnadj{vacuous}{initialization}
3453-
if it is default-initialized and,
3463+
if it is default-initialized, no other initialization is performed, and,
34543464
if it is of class type or a (possibly multidimensional) array thereof,
3455-
that class type has a trivial default constructor.
3465+
a trivial constructor of that class type is selected for
3466+
the default-initialization.
34563467
The lifetime of an object of type \tcode{T} begins when:
34573468
\begin{itemize}
34583469
\item storage with the proper alignment and size
@@ -4431,7 +4442,7 @@
44314442

44324443
\pnum
44334444
When an object of class type \tcode{X}
4434-
is passed to or returned from a function,
4445+
is passed to or returned from a potentially-evaluated function call,
44354446
if \tcode{X} has at least one eligible copy or move constructor\iref{special},
44364447
each such constructor is trivial,
44374448
and the destructor of \tcode{X} is either trivial or deleted,
@@ -4454,11 +4465,6 @@
44544465
\indextext{temporary!constructor for}%
44554466
\indextext{temporary!destructor for}%
44564467
\indextext{temporary!destruction of}%
4457-
When an implementation introduces a temporary object of a class that has a
4458-
non-trivial constructor\iref{class.default.ctor,class.copy.ctor},
4459-
it shall ensure that a constructor is called for the temporary object.
4460-
Similarly, the destructor shall be called for a temporary with a non-trivial
4461-
destructor\iref{class.dtor}.
44624468
Temporary objects are destroyed as the last step
44634469
in evaluating
44644470
the full-expression\iref{intro.execution}
@@ -4476,7 +4482,7 @@
44764482
\pnum
44774483
\indextext{initializer!temporary and declarator}%
44784484
\indextext{temporary!order of destruction of}%
4479-
There are four contexts in which temporaries are destroyed at a different
4485+
There are five contexts in which temporaries are destroyed at a different
44804486
point than the end of the full-expression.
44814487
The first context is when a default constructor is called to initialize
44824488
an element of an array with no corresponding initializer\iref{dcl.init}.
@@ -4602,6 +4608,14 @@
46024608
the object persists for the lifetime of the reference
46034609
initialized by the \grammarterm{for-range-initializer}.
46044610

4611+
\pnum
4612+
The fifth context is when a temporary object
4613+
is created in a structured binding declaration\iref{dcl.struct.bind}.
4614+
Any temporary objects introduced by
4615+
the \grammarterm{initializer}{s} for the variables
4616+
with unique names
4617+
are destroyed at the end of the structured binding declaration.
4618+
46054619
\pnum
46064620
Let \tcode{x} and \tcode{y} each be either
46074621
a temporary object whose lifetime is not extended, or
@@ -5760,6 +5774,15 @@
57605774
An extended floating-point type with the same set of values as
57615775
more than one cv-unqualified standard floating-point type
57625776
has a rank equal to the rank of \keyword{double}.
5777+
\begin{tailnote}
5778+
The treatment of \tcode{std::float64_t} differs from
5779+
that of the analoguous \tcode{_Float64} in C,
5780+
for example on platforms where all of
5781+
\tcode{\keyword{long} \keyword{double}},
5782+
\keyword{double}, and
5783+
\tcode{std::float64_t}
5784+
have the same set of values (see \IsoCUndated{}:2024 H.4.2).
5785+
\end{tailnote}
57635786
\end{itemize}
57645787
\begin{note}
57655788
The conversion ranks of floating-point types \tcode{T1} and \tcode{T2}
@@ -5878,7 +5901,8 @@
58785901
\item
58795902
an immediate invocation\iref{expr.const},
58805903
\item
5881-
an \grammarterm{init-declarator}\iref{dcl.decl} or
5904+
an \grammarterm{init-declarator}\iref{dcl.decl}
5905+
(including such introduced by a structured binding\iref{dcl.struct.bind}) or
58825906
a \grammarterm{mem-initializer}\iref{class.base.init},
58835907
including the constituent expressions of the initializer,
58845908
\item

source/classes.tex

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@
12171217
has a default argument
12181218
(including the case of a constructor with no parameters).
12191219
\indextext{implicitly-declared default constructor}%
1220-
If there is no user-declared constructor for class
1220+
If there is no user-declared constructor or constructor template for class
12211221
\tcode{X},
12221222
a non-explicit constructor having no parameters is implicitly declared
12231223
as defaulted\iref{dcl.fct.def}.
@@ -4860,12 +4860,6 @@
48604860
\end{codeblock}
48614861
\end{example}
48624862

4863-
\pnum
4864-
\indextext{friend function!linkage of}%
4865-
A function first declared in a friend declaration
4866-
has the linkage of the namespace of which it is a member\iref{basic.link}.
4867-
Otherwise, the function retains its previous linkage\iref{dcl.stc}.
4868-
48694863
\pnum
48704864
\indextext{declaration!overloaded name and \tcode{friend}}%
48714865
\begin{note}

source/compatibility.tex

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,28 @@
19971997
\end{codeblock}
19981998
\end{example}
19991999

2000+
\diffref{expr.typeid}
2001+
\change
2002+
Evaluation of operands in \keyword{typeid}.
2003+
\rationale
2004+
Introduce additional expression value categories.
2005+
\effect
2006+
Valid \CppIII{} code that uses xvalues as operands for \keyword{typeid}
2007+
may change behavior in this revision of \Cpp{}.
2008+
\begin{example}
2009+
\begin{codeblock}
2010+
void f() {
2011+
struct B {
2012+
B() {}
2013+
virtual ~B() { }
2014+
};
2015+
2016+
struct C { B b; };
2017+
typeid(C().b); // unevaluated in \CppIII{}, evaluated in \CppXI{}
2018+
}
2019+
\end{codeblock}
2020+
\end{example}
2021+
20002022
\diffref{expr.mul}
20012023
\change
20022024
Specify rounding for results of integer \tcode{/} and \tcode{\%}.
@@ -2023,6 +2045,31 @@
20232045
\end{codeblock}
20242046
\end{example}
20252047

2048+
\diffref{expr.cond}
2049+
\change
2050+
Fewer copies in the conditional operator.
2051+
\rationale
2052+
Introduce additional expression value categories.
2053+
\effect
2054+
Valid \CppIII{} code that uses xvalues as operands for the conditional operator
2055+
may change behavior in this revision of \Cpp{}.
2056+
\begin{example}
2057+
\begin{codeblock}
2058+
void f() {
2059+
struct B {
2060+
B() {}
2061+
B(const B&) { }
2062+
};
2063+
struct D : B {};
2064+
2065+
struct BB { B b; };
2066+
struct DD { D d; };
2067+
2068+
true ? BB().b : DD().d; // additional copy in \CppIII{}, no copy or move in \CppXI{}
2069+
}
2070+
\end{codeblock}
2071+
\end{example}
2072+
20262073
\rSec2[diff.cpp03.dcl.dcl]{\ref{dcl.dcl}: declarations}
20272074

20282075
\diffref{dcl.spec}

source/declarations.tex

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,10 @@
15121512
\indextext{name!elaborated!\idxcode{enum}}%
15131513
If an \grammarterm{elaborated-type-specifier} is the sole constituent of a
15141514
declaration, the declaration is ill-formed unless it is an explicit
1515-
specialization\iref{temp.expl.spec}, an explicit
1516-
instantiation\iref{temp.explicit} or it has one of the following
1515+
specialization\iref{temp.expl.spec},
1516+
a partial specialization\iref{temp.spec.partial},
1517+
an explicit
1518+
instantiation\iref{temp.explicit}, or it has one of the following
15171519
forms:
15181520

15191521
\begin{ncsimplebnf}
@@ -1527,7 +1529,7 @@
15271529
The second case shall appear only
15281530
in an \grammarterm{explicit-specialization}\iref{temp.expl.spec} or
15291531
in a \grammarterm{template-declaration}
1530-
(where it declares a partial specialization\iref{temp.decls}).
1532+
(where it declares a partial specialization).
15311533
The \grammarterm{attribute-specifier-seq}, if any, appertains
15321534
to the class or template being declared.
15331535

@@ -4629,15 +4631,10 @@
46294631
If
46304632
\tcode{T}
46314633
is a (possibly cv-qualified) class type\iref{class}, then
4632-
\begin{itemize}
4633-
\item
4634-
if \tcode{T} has
4635-
either no default constructor\iref{class.default.ctor} or a default
4636-
constructor that is user-provided or deleted, then the object is default-initialized;
4637-
\item
4638-
otherwise,
4639-
the object is zero-initialized and then default-initialized.
4640-
\end{itemize}
4634+
let \tcode{C} be the constructor selected to
4635+
default-initialize the object, if any.
4636+
If \tcode{C} is not user-provided, the object is first zero-initialized.
4637+
In all cases, the object is then default-initialized.
46414638

46424639
\item
46434640
If
@@ -4708,7 +4705,7 @@
47084705
The
47094706
\indextext{type!destination}%
47104707
\term{destination type}
4711-
is the type of the object or reference being initialized and the
4708+
is the cv-unqualified type of the object or reference being initialized and the
47124709
\term{source type}
47134710
is the type of the initializer expression.
47144711
If the initializer is not a single (possibly parenthesized) expression, the
@@ -4769,21 +4766,21 @@
47694766
is sequenced before those associated with
47704767
the initialization of the $j^\text{th}$ element.
47714768
\item
4772-
Otherwise, if the destination type is a (possibly cv-qualified) class type:
4769+
Otherwise, if the destination type is a class type:
47734770

47744771
\begin{itemize}
47754772
\item
47764773
If the initializer expression is a prvalue
47774774
and the cv-unqualified version of the source type
4778-
is the same class as the class of the destination,
4775+
is the same as the destination type,
47794776
the initializer expression is used to initialize the destination object.
47804777
\begin{example}
47814778
\tcode{T x = T(T(T()));} value-initializes \tcode{x}.
47824779
\end{example}
47834780
\item
47844781
Otherwise, if the initialization is direct-initialization,
47854782
or if it is copy-initialization where the cv-unqualified version of the source
4786-
type is the same class as, or a derived class of, the class of the destination,
4783+
type is the same as or is derived from the class of the destination type,
47874784
constructors are considered.
47884785
The applicable constructors
47894786
are enumerated\iref{over.match.ctor}, and the best one is chosen
@@ -4880,7 +4877,7 @@
48804877
the (possibly converted) value of the initializer expression.
48814878
A standard conversion sequence\iref{conv} is used
48824879
to convert the initializer expression to
4883-
a prvalue of the cv-unqualified version of
4880+
a prvalue of
48844881
the destination type;
48854882
no user-defined conversions are considered.
48864883
If the conversion cannot
@@ -6263,10 +6260,9 @@
62636260
\item from a floating-point type \tcode{T} to another floating-point type
62646261
whose floating-point conversion rank is neither greater than nor equal to
62656262
that of \tcode{T},
6266-
except where the source is a constant expression and
6267-
the actual value after conversion
6268-
is within the range of values that can be represented (even if it cannot be represented exactly),
6269-
or
6263+
except where the result of the conversion is a constant expression and
6264+
either its value is finite and the conversion did not overflow, or
6265+
the values before and after the conversion are not finite, or
62706266

62716267
\item from an integer type or unscoped enumeration type to a floating-point type, except
62726268
where the source is a constant expression and the actual value after conversion will fit
@@ -7105,6 +7101,10 @@
71057101
Each $\tcode{v}_i$ is the name of an lvalue of type $\tcode{T}_i$
71067102
that refers to the object bound to $\tcode{r}_i$;
71077103
the referenced type is $\tcode{T}_i$.
7104+
The initialization of \exposid{e} is
7105+
sequenced before the initialization of any $\tcode{r}_i$.
7106+
The initialization of each $\tcode{r}_i$ is
7107+
sequenced before the initialization of any $\tcode{r}_j$ where $i < j$.
71087108

71097109
\pnum
71107110
Otherwise,
@@ -7477,11 +7477,26 @@
74777477
\pnum
74787478
A \grammarterm{using-enum-declarator}
74797479
names the set of declarations found by
7480-
lookup\iref{basic.lookup.unqual,basic.lookup.qual}
7481-
for the \grammarterm{using-enum-declarator}.
7480+
type-only lookup\iref{basic.lookup.general}
7481+
for the \grammarterm{using-enum-declarator}\iref{basic.lookup.unqual,basic.lookup.qual}.
74827482
The \grammarterm{using-enum-declarator}
74837483
shall designate a non-dependent type
74847484
with a reachable \grammarterm{enum-specifier}.
7485+
\begin{example}
7486+
\begin{codeblock}
7487+
enum E { x };
7488+
void f() {
7489+
int E;
7490+
using enum E; // OK
7491+
}
7492+
using F = E;
7493+
using enum F; // OK
7494+
template<class T> using EE = T;
7495+
void g() {
7496+
using enum EE<E>; // OK
7497+
}
7498+
\end{codeblock}
7499+
\end{example}
74857500

74867501
\pnum
74877502
A \grammarterm{using-enum-declaration}

0 commit comments

Comments
 (0)