Skip to content

Commit 9e41261

Browse files
authored
Merge 2024-11 CWG Motion 1
P3524R0 Core Language Working Group "ready" Issues
2 parents 10668dc + 8f6236e commit 9e41261

11 files changed

+419
-203
lines changed

source/basic.tex

+53-13
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@
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}, or
514+
\item the intervening scope is the function parameter scope of
515+
a \grammarterm{lambda-expression} or \grammarterm{requires-expression}, or
515516
\item the intervening scope is the lambda scope of
516517
a \grammarterm{lambda-expression}
517518
that has a \grammarterm{simple-capture}
@@ -3115,7 +3116,9 @@
31153116
\end{note}
31163117

31173118
\pnum
3118-
A \defn{memory location} is either an object of scalar type that is not a bit-field
3119+
A \defn{memory location} is
3120+
the storage occupied by the object representation of
3121+
either an object of scalar type that is not a bit-field
31193122
or a maximal sequence of adjacent bit-fields all having nonzero width.
31203123
\begin{note}
31213124
Various
@@ -5515,7 +5518,7 @@
55155518
A pointer value $P$ is
55165519
\indextext{value!valid in the context of an evaluation}%
55175520
\defn{valid in the context of} an evaluation $E$
5518-
if $P$ is a null pointer value, or
5521+
if $P$ is a pointer to function or a null pointer value, or
55195522
if it is a pointer to or past the end of an object $O$ and
55205523
$E$ happens before the end of the duration of the region of storage for $O$.
55215524
If a pointer value $P$ is used in an evaluation $E$ and
@@ -6037,13 +6040,30 @@
60376040
\end{note}
60386041
The value computations of the operands of an
60396042
operator are sequenced before the value computation of the result of the
6040-
operator. If a
6043+
operator.
6044+
The behavior is undefined if
6045+
\begin{itemize}
6046+
\item
60416047
\indextext{side effects}%
6042-
side effect on a memory location\iref{intro.memory} is unsequenced
6043-
relative to either another side effect on the same memory location or
6048+
a side effect on a memory location\iref{intro.memory} or
6049+
\item
6050+
starting or ending the lifetime of an object in a memory location
6051+
\end{itemize}
6052+
is unsequenced relative to
6053+
\begin{itemize}
6054+
\item
6055+
another side effect on the same memory location,
6056+
\item
6057+
starting or ending the lifetime of an object occupying storage that
6058+
overlaps with the memory location, or
6059+
\item
60446060
a value computation using the value of any object in the same memory location,
6045-
and they are not potentially concurrent\iref{intro.multithread},
6046-
the behavior is undefined.
6061+
\end{itemize}
6062+
and the two evaluations are not potentially concurrent\iref{intro.multithread}.
6063+
\begin{note}
6064+
Starting the lifetime of an object in a memory location can end the lifetime of
6065+
objects in other memory locations\iref{basic.life}.
6066+
\end{note}
60476067
\begin{note}
60486068
The next subclause imposes similar, but more complex restrictions on
60496069
potentially concurrent computations.
@@ -6057,6 +6077,9 @@
60576077
i = i++ + 1; // the value of \tcode{i} is incremented
60586078
i = i++ + i; // undefined behavior
60596079
i = i + 1; // the value of \tcode{i} is incremented
6080+
6081+
union U { int x, y; } u;
6082+
(u.x = 1, 0) + (u.y = 2, 0); // undefined behavior
60606083
}
60616084
\end{codeblock}
60626085
\end{example}
@@ -6067,8 +6090,13 @@
60676090
the postfix expression designating the called function
60686091
are sequenced before every expression or statement
60696092
in the body of the called function.
6070-
For each function invocation or
6071-
evaluation of an \grammarterm{await-expression} \placeholder{F},
6093+
For each
6094+
\begin{itemize}
6095+
\item function invocation,
6096+
\item evaluation of an \grammarterm{await-expression}\iref{expr.await}, or
6097+
\item evaluation of a \grammarterm{throw-expression}\iref{expr.throw}
6098+
\end{itemize}
6099+
\placeholder{F},
60726100
each evaluation that does not occur within \placeholder{F} but
60736101
is evaluated on the same thread and as part of the same signal handler (if any)
60746102
is either sequenced before all evaluations that occur within \placeholder{F}
@@ -6167,9 +6195,21 @@
61676195
\end{note}
61686196

61696197
\pnum
6170-
Two expression evaluations \defn{conflict} if one of them modifies\iref{defns.access} a memory
6171-
location\iref{intro.memory} and the other one reads or modifies the same
6172-
memory location.
6198+
Two expression evaluations \defn{conflict} if one of them
6199+
\begin{itemize}
6200+
\item
6201+
modifies\iref{defns.access} a memory location\iref{intro.memory} or
6202+
\item
6203+
starts or ends the lifetime of an object in a memory location
6204+
\end{itemize}
6205+
and the other one
6206+
\begin{itemize}
6207+
\item
6208+
reads or modifies the same memory location or
6209+
\item
6210+
starts or ends the lifetime of an object occupying storage that
6211+
overlaps with the memory location.
6212+
\end{itemize}
61736213
\begin{note}
61746214
A modification can still conflict
61756215
even if it does not alter the value of any bits.

source/classes.tex

+29-27
Original file line numberDiff line numberDiff line change
@@ -3331,13 +3331,13 @@
33313331

33323332
\pnum
33333333
\indextext{nested class!local class}%
3334-
If class \tcode{X} is a local class, a nested class \tcode{Y} may be
3335-
declared in class \tcode{X} and later defined in the definition of class
3336-
\tcode{X} or be later defined in the same scope as the definition of
3337-
class \tcode{X}.
33383334
\indextext{restriction!local class}%
33393335
A class nested within
33403336
a local class is a local class.
3337+
A member of a local class \tcode{X} shall be
3338+
declared only in the definition of \tcode{X} or,
3339+
if the member is a nested class,
3340+
in the nearest enclosing block scope of \tcode{X}.
33413341

33423342
\pnum
33433343
\indextext{restriction!static member local class}%
@@ -6178,60 +6178,62 @@
61786178
\indextext{constructor!copy!elision}%
61796179
\indextext{constructor!move!elision}%
61806180
When certain criteria are met, an implementation is
6181-
allowed to omit the copy/move construction of a class object,
6182-
even if the constructor selected for the copy/move operation and/or the
6181+
allowed to omit the creation of a class object from
6182+
a source object of the same type (ignoring cv-qualification),
6183+
even if the selected constructor and/or the
61836184
destructor for the object have
61846185
\indextext{side effects}%
61856186
side effects. In such cases, the
61866187
implementation treats the source and target of the
6187-
omitted copy/move operation as simply two different ways of
6188+
omitted initialization as simply two different ways of
61886189
referring to the same object. If the first parameter of the
61896190
selected constructor is an rvalue reference to the object's type,
61906191
the destruction of that object occurs when the target would have been destroyed;
61916192
otherwise, the destruction occurs at the later of the times when the
61926193
two objects would have been destroyed without the
61936194
optimization.
6194-
\begin{footnote}
6195+
\begin{note}
61956196
Because only one object is destroyed instead of two,
6196-
and one copy/move constructor
6197-
is not executed, there is still one object destroyed for each one constructed.
6198-
\end{footnote}
6199-
This elision of copy/move operations, called
6197+
and the creation of one object is omitted,
6198+
there is still one object destroyed for each one constructed.
6199+
\end{note}
6200+
This elision of object creation, called
62006201
\indexdefn{copy elision|see{constructor, copy, elision}}%
62016202
\indexdefn{elision!copy|see{constructor, copy, elision}}%
62026203
\indexdefn{constructor!copy!elision}\indexdefn{constructor!move!elision}\term{copy elision},
62036204
is permitted in the
62046205
following circumstances (which may be combined to
62056206
eliminate multiple copies):
62066207
\begin{itemize}
6207-
\item in a \tcode{return} statement in a function with a class return type,
6208+
\item in a \tcode{return} statement\iref{stmt.return} in
6209+
a function with a class return type,
62086210
when the \grammarterm{expression} is the name of a non-volatile
6209-
object with automatic storage duration (other than a function parameter or a variable
6211+
object $o$ with automatic storage duration (other than a function parameter or a variable
62106212
introduced by the \grammarterm{exception-declaration} of a
6211-
\grammarterm{handler}\iref{except.handle})
6212-
with the same type (ignoring cv-qualification) as
6213-
the function return type, the copy/move operation can be
6214-
omitted by constructing the object directly
6215-
into the function call's return object
6213+
\grammarterm{handler}\iref{except.handle}),
6214+
the copy-initialization of the result object can be
6215+
omitted by constructing $o$ directly
6216+
into the function call's result object;
62166217

62176218
\item in a \grammarterm{throw-expression}\iref{expr.throw}, when the operand
6218-
is the name of a non-volatile object with automatic storage duration
6219-
(other than a function or catch-clause parameter)
6219+
is the name of a non-volatile object $o$ with automatic storage duration
6220+
(other than a function parameter or
6221+
a variable introduced by
6222+
the \grammarterm{exception-declaration} of a \grammarterm{handler})
62206223
that belongs to a scope that does not contain
62216224
the innermost enclosing \grammarterm{compound-statement}
62226225
associated with a \grammarterm{try-block} (if there is one),
6223-
the copy/move operation can be omitted by
6224-
constructing the object directly into the exception object
6226+
the copy-initialization of the exception object can be omitted by
6227+
constructing $o$ directly into the exception object;
62256228

62266229
\item in a coroutine\iref{dcl.fct.def.coroutine}, a copy of a coroutine parameter
62276230
can be omitted and references to that copy replaced with references to the
62286231
corresponding parameter if the meaning of the program will be unchanged except for
6229-
the execution of a constructor and destructor for the parameter copy object
6232+
the execution of a constructor and destructor for the parameter copy object;
62306233

62316234
\item when the \grammarterm{exception-declaration} of a
6232-
\grammarterm{handler}\iref{except.handle} declares an object of the same
6233-
type (except for cv-qualification) as the exception
6234-
object\iref{except.throw}, the copy operation can be omitted by treating
6235+
\grammarterm{handler}\iref{except.handle} declares an object $o$,
6236+
the copy-initialization of $o$ can be omitted by treating
62356237
the \grammarterm{exception-declaration} as an alias for the exception
62366238
object if the meaning of the program will be unchanged except for the execution
62376239
of constructors and destructors for the object declared by the

source/compatibility.tex

+32
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,38 @@
122122
\end{codeblock}
123123
\end{example}
124124

125+
\diffref{temp.deduct.call}
126+
\change
127+
Template argument deduction from overload sets succeeds in more cases.
128+
\rationale
129+
Allow consideration of constraints to disambiguate overload sets
130+
used as parameters in function calls.
131+
\effect
132+
Valid \CppXXIII{} code may become ill-formed.
133+
\begin{example}
134+
\begin{codeblock}
135+
template <typename T>
136+
void f(T &&, void (*)(T &&));
137+
138+
void g(int &); // \#1
139+
inline namespace A {
140+
void g(short &&); // \#2
141+
}
142+
inline namespace B {
143+
void g(short &&); // \#3
144+
}
145+
146+
void q() {
147+
int x;
148+
f(x, g); // ill-formed; previously well-formed, deducing \tcode{T = int\&}
149+
}
150+
\end{codeblock}
151+
There is no change to the applicable deduction rules for
152+
the individual \tcode{g} candidates:
153+
Type deduction from \#1 does not succeed;
154+
type deductions from \#2 and \#3 both succeed.
155+
\end{example}
156+
125157
\rSec2[diff.cpp23.library]{\ref{library}: library introduction}
126158

127159
\diffref{headers}

source/declarations.tex

+15-4
Original file line numberDiff line numberDiff line change
@@ -3641,7 +3641,7 @@
36413641
If the
36423642
\grammarterm{parameter-declaration-clause}
36433643
is empty, the function takes no arguments.
3644-
A parameter list consisting of a single unnamed parameter of
3644+
A parameter list consisting of a single unnamed non-object parameter of
36453645
non-dependent type \keyword{void} is equivalent to an empty parameter
36463646
list.
36473647
\indextext{parameter!\idxcode{void}}%
@@ -5810,6 +5810,10 @@
58105810
return x;
58115811
}
58125812
constexpr int z = f(); // error: not a constant expression
5813+
5814+
typedef int *A[3]; // array of 3 pointer to \tcode{int}
5815+
typedef const int *const CA[3]; // array of 3 const pointer to \tcode{const int}
5816+
ACPC &&r = AP{}; // binds directly
58135817
\end{codeblock}
58145818
\end{example}
58155819

@@ -9011,6 +9015,7 @@
90119015

90129016
\rSec2[dcl.attr.assume]{Assumption attribute}
90139017

9018+
\pnum
90149019
The \grammarterm{attribute-token} \tcode{assume} may be applied to a null statement;
90159020
such a statement is an \defn{assumption}.
90169021
An \grammarterm{attribute-argument-clause} shall be present and
@@ -9023,7 +9028,10 @@
90239028
If the converted expression would evaluate to \tcode{true}
90249029
at the point where the assumption appears,
90259030
the assumption has no effect.
9026-
Otherwise, the behavior is undefined.
9031+
Otherwise,
9032+
evaluation of the assumption has runtime-undefined behavior.
9033+
9034+
\pnum
90279035
\begin{note}
90289036
The expression is potentially evaluated\iref{basic.def.odr}.
90299037
The use of assumptions is intended to allow implementations
@@ -9037,6 +9045,8 @@
90379045
if an implementation does not attempt to deduce
90389046
any such information from assumptions.
90399047
\end{note}
9048+
9049+
\pnum
90409050
\begin{example}
90419051
\begin{codeblock}
90429052
int divide_by_32(int x) {
@@ -9530,8 +9540,9 @@
95309540
translation unit, the program is ill-formed, no diagnostic required.
95319541

95329542
\pnum
9533-
If a function \tcode{f} is called where \tcode{f} was previously declared with the \tcode{noreturn}
9534-
attribute and \tcode{f} eventually returns, the behavior is undefined.
9543+
If a function \tcode{f} is invoked where \tcode{f} was previously declared with the \tcode{noreturn}
9544+
attribute and that invocation eventually returns,
9545+
the behavior is runtime-undefined.
95359546
\begin{note}
95369547
The function can
95379548
terminate by throwing an exception.

0 commit comments

Comments
 (0)