Skip to content

[CWG motion 1 2024-06] P3345R0 all issues except 2819, 2858, and 2876 #7099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2e188e5
CWG233 References vs pointers in UDC overload resolution
burblebee Jul 1, 2024
4596a87
CWG2561 Conversion to function pointer for lambda with explicit objec…
burblebee Jul 1, 2024
0c6f5bc
CWG2588 friend declarations and module linkage
burblebee Jul 1, 2024
f47cbe4
CWG2728 Evaluation of conversions in a delete-expression
burblebee Jul 1, 2024
ba8ff83
CWG2818 Use of predefined reserved identifiers
burblebee Jul 1, 2024
e242072
CWG2836 Conversion rank of long double and extended floating-point types
burblebee Jul 1, 2024
2785faa
CWG2859 Value-initialization with multiple default constructors
burblebee Jul 1, 2024
ac4ca28
CWG2861 dynamic_cast on bad pointer value
burblebee Jul 1, 2024
6230b30
CWG2864 Narrowing floating-point conversions
burblebee Jul 1, 2024
3ca9529
CWG2865 Regression on result of conditional operator
burblebee Jul 1, 2024
f7ee4d7
CWG2867 Order of initialization for structured bindings
burblebee Jul 1, 2024
aa46088
CWG2869 this in local classes
burblebee Jul 1, 2024
f368144
CWG2870 Combining absent encoding-prefixes
burblebee Jul 2, 2024
f6ab13f
CWG2871 User-declared constructor templates inhibiting default constr…
burblebee Jul 2, 2024
be6efd9
CWG2872 Linkage and unclear "can be referred to"
burblebee Jul 2, 2024
4ceed3f
CWG2874 Qualified declarations of partial specializations
burblebee Jul 2, 2024
76bf42d
CWG2877 Type-only lookup for using-enum-declarator
burblebee Jul 2, 2024
0193ee8
CWG2881 Type restrictions for the explicit object parameter of a lambda
burblebee Jul 2, 2024
3d5d613
CWG2882 Unclear treatment of conversion to void
burblebee Jul 2, 2024
7c74329
CWG2883 Definition of "odr-usable" ignores lambda scopes
burblebee Jul 2, 2024
56758c0
CWG2886 Temporaries and trivial potentially-throwing special member f…
burblebee Jul 2, 2024
8400611
CWG2887 Missing compatibility entries for xvalues
burblebee Jul 2, 2024
f20464d
CWG2891 Normative status of implementation limits
burblebee Jul 2, 2024
a09f17d
CWG2892 Unclear usual arithmetic conversions
burblebee Jul 2, 2024
8f43f8d
CWG2895 Initialization should ignore the destination type's cv-qualif…
burblebee Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 57 additions & 33 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,9 @@
either:
\begin{itemize}
\item the intervening scope is a block scope, or
\item the intervening scope is the function parameter scope of a \grammarterm{lambda-expression}
\item the intervening scope is the function parameter scope of a \grammarterm{lambda-expression}, or
\item the intervening scope is the lambda scope of
a \grammarterm{lambda-expression}
that has a \grammarterm{simple-capture}
naming the entity or has a \grammarterm{capture-default}, and
the block scope of the \grammarterm{lambda-expression}
Expand Down Expand Up @@ -2664,28 +2666,18 @@

\pnum
\indextext{translation unit}%
A name is said to have \defn{linkage} when it can denote the same
object, reference, function, type, template, namespace or value as a
name introduced by a declaration in another scope:
\begin{itemize}
\item When a name has \defnadj{external}{linkage},
the entity it denotes
can be referred to by names from scopes of other translation units or
from other scopes of the same translation unit.

\item When a name has \defnx{module linkage}{linkage!module},
the entity it denotes
can be referred to by names from other scopes of the same module unit\iref{module.unit} or
from scopes of other module units of that same module.

\item When a name has \defnadj{internal}{linkage},
the entity it denotes
can be referred to by names from other scopes in the same translation
unit.

\item When a name has \indextext{linkage!no}\defn{no linkage}, the entity it denotes
cannot be referred to by names from other scopes.
\end{itemize}
A name can have
\defnadj{external}{linkage},
\defnadj{module}{linkage},
\defnadj{internal}{linkage}, or
\defnadj{no}{linkage},
as determined by the rules below.
\begin{note}
All declarations of an entity with a name with internal linkage
appear in the same translation unit.
All declarations of an entity with module linkage
are attached to the same module.
\end{note}

\pnum
\indextext{linkage!\idxcode{static} and}%
Expand Down Expand Up @@ -2746,6 +2738,24 @@
has its linkage determined as follows:
\begin{itemize}
\item
\indextext{friend function!linkage of}%
if the entity is a function or function template
first declared in a friend declaration and
that declaration is a definition and
the enclosing class is defined within an \grammarterm{export-declaration},
the name has the same linkage, if any,
as the name of the enclosing class\iref{class.friend};
\item
otherwise,
\indextext{friend function!linkage of}%
if the entity is a function or function template
declared in a friend declaration and
a corresponding non-friend declaration is reachable,
%FIXME: Which declaration is "that prior declaration"?
%FIXME: "prior" with respect to what? And what about dependent lookup?
the name has the linkage determined from that prior declaration,
\item
otherwise,
if the enclosing namespace has internal linkage,
the name has internal linkage;
\item
Expand Down Expand Up @@ -3450,9 +3460,10 @@
The \defn{lifetime} of an object or reference is a runtime property of the
object or reference.
A variable is said to have \defnadj{vacuous}{initialization}
if it is default-initialized and,
if it is default-initialized, no other initialization is performed, and,
if it is of class type or a (possibly multidimensional) array thereof,
that class type has a trivial default constructor.
a trivial constructor of that class type is selected for
the default-initialization.
The lifetime of an object of type \tcode{T} begins when:
\begin{itemize}
\item storage with the proper alignment and size
Expand Down Expand Up @@ -4431,7 +4442,7 @@

\pnum
When an object of class type \tcode{X}
is passed to or returned from a function,
is passed to or returned from a potentially-evaluated function call,
if \tcode{X} has at least one eligible copy or move constructor\iref{special},
each such constructor is trivial,
and the destructor of \tcode{X} is either trivial or deleted,
Expand All @@ -4454,11 +4465,6 @@
\indextext{temporary!constructor for}%
\indextext{temporary!destructor for}%
\indextext{temporary!destruction of}%
When an implementation introduces a temporary object of a class that has a
non-trivial constructor\iref{class.default.ctor,class.copy.ctor},
it shall ensure that a constructor is called for the temporary object.
Similarly, the destructor shall be called for a temporary with a non-trivial
destructor\iref{class.dtor}.
Temporary objects are destroyed as the last step
in evaluating
the full-expression\iref{intro.execution}
Expand All @@ -4476,7 +4482,7 @@
\pnum
\indextext{initializer!temporary and declarator}%
\indextext{temporary!order of destruction of}%
There are four contexts in which temporaries are destroyed at a different
There are five contexts in which temporaries are destroyed at a different
point than the end of the full-expression.
The first context is when a default constructor is called to initialize
an element of an array with no corresponding initializer\iref{dcl.init}.
Expand Down Expand Up @@ -4602,6 +4608,14 @@
the object persists for the lifetime of the reference
initialized by the \grammarterm{for-range-initializer}.

\pnum
The fifth context is when a temporary object
is created in a structured binding declaration\iref{dcl.struct.bind}.
Any temporary objects introduced by
the \grammarterm{initializer}{s} for the variables
with unique names
are destroyed at the end of the structured binding declaration.

\pnum
Let \tcode{x} and \tcode{y} each be either
a temporary object whose lifetime is not extended, or
Expand Down Expand Up @@ -5760,6 +5774,15 @@
An extended floating-point type with the same set of values as
more than one cv-unqualified standard floating-point type
has a rank equal to the rank of \keyword{double}.
\begin{tailnote}
The treatment of \tcode{std::float64_t} differs from
that of the analoguous \tcode{_Float64} in C,
for example on platforms where all of
\tcode{\keyword{long} \keyword{double}},
\keyword{double}, and
\tcode{std::float64_t}
have the same set of values (see \IsoCUndated{}:2024 H.4.2).
\end{tailnote}
\end{itemize}
\begin{note}
The conversion ranks of floating-point types \tcode{T1} and \tcode{T2}
Expand Down Expand Up @@ -5878,7 +5901,8 @@
\item
an immediate invocation\iref{expr.const},
\item
an \grammarterm{init-declarator}\iref{dcl.decl} or
an \grammarterm{init-declarator}\iref{dcl.decl}
(including such introduced by a structured binding\iref{dcl.struct.bind}) or
a \grammarterm{mem-initializer}\iref{class.base.init},
including the constituent expressions of the initializer,
\item
Expand Down
8 changes: 1 addition & 7 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@
has a default argument
(including the case of a constructor with no parameters).
\indextext{implicitly-declared default constructor}%
If there is no user-declared constructor for class
If there is no user-declared constructor or constructor template for class
\tcode{X},
a non-explicit constructor having no parameters is implicitly declared
as defaulted\iref{dcl.fct.def}.
Expand Down Expand Up @@ -4860,12 +4860,6 @@
\end{codeblock}
\end{example}

\pnum
\indextext{friend function!linkage of}%
A function first declared in a friend declaration
has the linkage of the namespace of which it is a member\iref{basic.link}.
Otherwise, the function retains its previous linkage\iref{dcl.stc}.

\pnum
\indextext{declaration!overloaded name and \tcode{friend}}%
\begin{note}
Expand Down
47 changes: 47 additions & 0 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,28 @@
\end{codeblock}
\end{example}

\diffref{expr.typeid}
\change
Evaluation of operands in \keyword{typeid}.
\rationale
Introduce additional expression value categories.
\effect
Valid \CppIII{} code that uses xvalues as operands for \keyword{typeid}
may change behavior in this revision of \Cpp{}.
\begin{example}
\begin{codeblock}
void f() {
struct B {
B() {}
virtual ~B() { }
};

struct C { B b; };
typeid(C().b); // unevaluated in \CppIII{}, evaluated in \CppXI{}
}
\end{codeblock}
\end{example}

\diffref{expr.mul}
\change
Specify rounding for results of integer \tcode{/} and \tcode{\%}.
Expand All @@ -2023,6 +2045,31 @@
\end{codeblock}
\end{example}

\diffref{expr.cond}
\change
Fewer copies in the conditional operator.
\rationale
Introduce additional expression value categories.
\effect
Valid \CppIII{} code that uses xvalues as operands for the conditional operator
may change behavior in this revision of \Cpp{}.
\begin{example}
\begin{codeblock}
void f() {
struct B {
B() {}
B(const B&) { }
};
struct D : B {};

struct BB { B b; };
struct DD { D d; };

true ? BB().b : DD().d; // additional copy in \CppIII{}, no copy or move in \CppXI{}
}
\end{codeblock}
\end{example}

\rSec2[diff.cpp03.dcl.dcl]{\ref{dcl.dcl}: declarations}

\diffref{dcl.spec}
Expand Down
61 changes: 38 additions & 23 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,10 @@
\indextext{name!elaborated!\idxcode{enum}}%
If an \grammarterm{elaborated-type-specifier} is the sole constituent of a
declaration, the declaration is ill-formed unless it is an explicit
specialization\iref{temp.expl.spec}, an explicit
instantiation\iref{temp.explicit} or it has one of the following
specialization\iref{temp.expl.spec},
a partial specialization\iref{temp.spec.partial},
an explicit
instantiation\iref{temp.explicit}, or it has one of the following
forms:

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

Expand Down Expand Up @@ -4629,15 +4631,10 @@
If
\tcode{T}
is a (possibly cv-qualified) class type\iref{class}, then
\begin{itemize}
\item
if \tcode{T} has
either no default constructor\iref{class.default.ctor} or a default
constructor that is user-provided or deleted, then the object is default-initialized;
\item
otherwise,
the object is zero-initialized and then default-initialized.
\end{itemize}
let \tcode{C} be the constructor selected to
default-initialize the object, if any.
If \tcode{C} is not user-provided, the object is first zero-initialized.
In all cases, the object is then default-initialized.

\item
If
Expand Down Expand Up @@ -4708,7 +4705,7 @@
The
\indextext{type!destination}%
\term{destination type}
is the type of the object or reference being initialized and the
is the cv-unqualified type of the object or reference being initialized and the
\term{source type}
is the type of the initializer expression.
If the initializer is not a single (possibly parenthesized) expression, the
Expand Down Expand Up @@ -4769,21 +4766,21 @@
is sequenced before those associated with
the initialization of the $j^\text{th}$ element.
\item
Otherwise, if the destination type is a (possibly cv-qualified) class type:
Otherwise, if the destination type is a class type:

\begin{itemize}
\item
If the initializer expression is a prvalue
and the cv-unqualified version of the source type
is the same class as the class of the destination,
is the same as the destination type,
the initializer expression is used to initialize the destination object.
\begin{example}
\tcode{T x = T(T(T()));} value-initializes \tcode{x}.
\end{example}
\item
Otherwise, if the initialization is direct-initialization,
or if it is copy-initialization where the cv-unqualified version of the source
type is the same class as, or a derived class of, the class of the destination,
type is the same as or is derived from the class of the destination type,
constructors are considered.
The applicable constructors
are enumerated\iref{over.match.ctor}, and the best one is chosen
Expand Down Expand Up @@ -4880,7 +4877,7 @@
the (possibly converted) value of the initializer expression.
A standard conversion sequence\iref{conv} is used
to convert the initializer expression to
a prvalue of the cv-unqualified version of
a prvalue of
the destination type;
no user-defined conversions are considered.
If the conversion cannot
Expand Down Expand Up @@ -6263,10 +6260,9 @@
\item from a floating-point type \tcode{T} to another floating-point type
whose floating-point conversion rank is neither greater than nor equal to
that of \tcode{T},
except where the source is a constant expression and
the actual value after conversion
is within the range of values that can be represented (even if it cannot be represented exactly),
or
except where the result of the conversion is a constant expression and
either its value is finite and the conversion did not overflow, or
the values before and after the conversion are not finite, or

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

\pnum
Otherwise,
Expand Down Expand Up @@ -7477,11 +7477,26 @@
\pnum
A \grammarterm{using-enum-declarator}
names the set of declarations found by
lookup\iref{basic.lookup.unqual,basic.lookup.qual}
for the \grammarterm{using-enum-declarator}.
type-only lookup\iref{basic.lookup.general}
for the \grammarterm{using-enum-declarator}\iref{basic.lookup.unqual,basic.lookup.qual}.
The \grammarterm{using-enum-declarator}
shall designate a non-dependent type
with a reachable \grammarterm{enum-specifier}.
\begin{example}
\begin{codeblock}
enum E { x };
void f() {
int E;
using enum E; // OK
}
using F = E;
using enum F; // OK
template<class T> using EE = T;
void g() {
using enum EE<E>; // OK
}
\end{codeblock}
\end{example}

\pnum
A \grammarterm{using-enum-declaration}
Expand Down
Loading
Loading