Skip to content

Commit cd27e1f

Browse files
authored
Merge 2025-11 CWG Motion 1
P3921R0 Core Language Working Group "ready" Issues for the November, 2025 meeting; excluding issues 1670, 2917, 2923, 3005, 3043, 3044, 3045, 3048, 3053, 3061, 3063, 3074, 3082, 3084, 3089, 3092, 3093, 3094, 3095, 3098, 3099, 3101, 3108, 3109, 3110, 3113, 3114, 3115, 3117, and 3118.
2 parents 176d615 + 5bfe790 commit cd27e1f

File tree

12 files changed

+415
-179
lines changed

12 files changed

+415
-179
lines changed

source/basic.tex

Lines changed: 107 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,8 @@
954954
declaration,
955955
\grammarterm{parameter-declaration-clause},
956956
\grammarterm{statement},
957-
\grammarterm{handler}, or
957+
\grammarterm{handler},
958+
\grammarterm{lambda-expression}, or
958959
contract assertion
959960
(as described in the following subclauses of \ref{basic.scope})
960961
appearing in another scope, which thereby contains $S$.
@@ -2887,8 +2888,8 @@
28872888
\indextext{program}%
28882889
\indextext{linking}%
28892890
A \defn{program} consists of one or more translation units\iref{lex.phases}
2890-
linked together. A translation unit consists
2891-
of a sequence of declarations.
2891+
that are translated and linked together.
2892+
A translation unit consists of a sequence of declarations.
28922893

28932894
\begin{bnf}
28942895
\nontermdef{translation-unit}\br
@@ -3476,7 +3477,7 @@
34763477
An object that is not a subobject of any other object is called a \defn{complete
34773478
object}.
34783479
If an object is created
3479-
in storage associated with a member subobject or array element \placeholder{e}
3480+
in storage associated with a subobject \placeholder{e}
34803481
(which may or may not be within its lifetime),
34813482
the created object
34823483
is a subobject of \placeholder{e}'s containing object if
@@ -3486,8 +3487,12 @@
34863487
\item
34873488
the storage for the new object exactly overlays the storage location associated with \placeholder{e}, and
34883489
\item
3490+
\placeholder{e} is not a potentially-overlapping subobject, and
3491+
\item
34893492
the new object is of the same type as \placeholder{e} (ignoring cv-qualification).
34903493
\end{itemize}
3494+
In this case, \placeholder{e} and the created object are
3495+
\defnadjx{corresponding direct}{subobjects}{subobject}.
34913496

34923497
\pnum
34933498
\indextext{object!providing storage for}%
@@ -3940,16 +3945,8 @@
39403945
the pointer is used to access a non-static data member or call a
39413946
non-static member function of the object, or
39423947
\item
3943-
the pointer is implicitly converted\iref{conv.ptr} to a pointer
3944-
to a virtual base class, or
3945-
\item
3946-
the pointer is used as the operand of a
3947-
\keyword{static_cast}\iref{expr.static.cast}, except when the conversion
3948-
is to pointer to \cv{}~\keyword{void}, or to pointer to \cv{}~\keyword{void}
3949-
and subsequently to pointer to
3950-
\cv{}~\keyword{char},
3951-
\cv{}~\tcode{\keyword{unsigned} \keyword{char}}, or
3952-
\cv{}~\tcode{std::byte}\iref{cstddef.syn}, or
3948+
the pointer is converted\iref{conv.ptr,expr.static.cast} to a pointer
3949+
to a virtual base class or to a base class thereof, or
39533950
\item
39543951
the pointer is used as the operand of a
39553952
\keyword{dynamic_cast}\iref{expr.dynamic.cast}.
@@ -4012,22 +4009,24 @@
40124009
\end{note}
40134010

40144011
\pnum
4015-
An object $o_1$ is \defn{transparently replaceable} by an object $o_2$ if
4012+
An object $o_1$ is \defn{transparently replaceable} by an object $o_2$ if either
4013+
\begin{itemize}
4014+
\item
4015+
$o_1$ and $o_2$ are complete objects for which:
40164016
\begin{itemize}
4017+
\item $o_1$ is not const,
40174018
\item the storage that $o_2$ occupies exactly overlays
40184019
the storage that $o_1$ occupied, and
4019-
40204020
\item $o_1$ and $o_2$ are of the same type
4021-
(ignoring the top-level cv-qualifiers), and
4022-
4023-
\item $o_1$ is not a const, complete object, and
4024-
4025-
\item neither $o_1$ nor $o_2$
4026-
is a potentially-overlapping subobject\iref{intro.object}, and
4021+
(ignoring the top-level cv-qualifiers), or
4022+
\end{itemize}
40274023

4028-
\item either $o_1$ and $o_2$ are both complete objects, or
4029-
$o_1$ and $o_2$ are direct subobjects of objects $p_1$ and $p_2$, respectively,
4030-
and $p_1$ is transparently replaceable by $p_2$.
4024+
\item
4025+
$o_1$ and $o_2$ are corresponding direct subobjects\iref{intro.object} for which:
4026+
\begin{itemize}
4027+
\item the complete object of $o_1$ is not const or
4028+
\item $o_1$ is a mutable member subobject or a subobject thereof.
4029+
\end{itemize}
40314030
\end{itemize}
40324031

40334032
\pnum
@@ -4812,7 +4811,9 @@
48124811
\item
48134812
a class member access\iref{expr.ref} using the \tcode{.} operator
48144813
where the left operand is one of these expressions and
4815-
the right operand designates a non-static data member of non-reference type,
4814+
the right operand designates
4815+
a non-static data member\iref{class.mem.general} of non-reference type or
4816+
a direct base class relationship\iref{class.derived.general},
48164817
\item
48174818
a pointer-to-member operation\iref{expr.mptr.oper} using the \tcode{.*} operator
48184819
where the left operand is one of these expressions and
@@ -4830,6 +4831,15 @@
48304831
to a glvalue that refers
48314832
to the object designated by the operand, or
48324833
to its complete object or a subobject thereof,
4834+
\item
4835+
an explicit type conversion (functional notation)\iref{expr.type.conv}
4836+
to a reference type whose initializer is a \grammarterm{braced-init-list}
4837+
where the reference is
4838+
\begin{itemize}
4839+
\item bound directly to the glvalue result of one of these expressions
4840+
(necessarily the sole element of the \grammarterm{braced-init-list}) or
4841+
\item bound to the result of a temporary materialization conversion,
4842+
\end{itemize}
48334843
\item
48344844
a conditional expression\iref{expr.cond} that is a glvalue
48354845
where the second or third operand is one of these expressions, or
@@ -5592,20 +5602,23 @@
55925602
is an incomplete type that cannot be completed; such a type has
55935603
an empty set of values. It is used as the return
55945604
type for functions that do not return a value.
5595-
An expression of type \cv{}~\keyword{void} shall
5596-
be used only as
5605+
\begin{note}
5606+
An expression of type \cv{}~\keyword{void} can be used as
55975607
\begin{itemize}
55985608
\item an expression statement\iref{stmt.expr},
55995609
\item the expression in a \keyword{return} statement\iref{stmt.return}
56005610
for a function with the return type \cv{}~\keyword{void},
56015611
\item an operand of a comma expression\iref{expr.comma},
5612+
\item the operand of a parenthesized expression\iref{expr.prim.paren},
5613+
\item a requirement in a \grammarterm{requires-expression}\iref{expr.prim.req.general},
56025614
\item the second or third operand of \tcode{?:}\iref{expr.cond},
56035615
\item the operand of a \keyword{typeid} expression\iref{expr.typeid},
56045616
\item the operand of a \keyword{noexcept} operator\iref{expr.unary.noexcept},
56055617
\item the operand of a \keyword{decltype} specifier\iref{dcl.type.decltype}, or
56065618
\item the operand of an explicit conversion to type
56075619
\cv{}~\keyword{void}\iref{expr.type.conv,expr.static.cast,expr.cast}.
56085620
\end{itemize}
5621+
\end{note}
56095622

56105623
\pnum
56115624
The types denoted by \cv~\tcode{std::nullptr_t} are distinct types.
@@ -7170,8 +7183,13 @@
71707183
\indextext{\idxcode{main} function!implementation-defined parameters to}%
71717184
An implementation shall allow both
71727185
\begin{itemize}
7173-
\item a function of \tcode{()} returning \keyword{int} and
7174-
\item a function of \tcode{(\keyword{int}}, pointer to pointer to \tcode{\keyword{char})} returning \keyword{int}
7186+
\item
7187+
an ``optionally \tcode{noexcept} function of
7188+
\tcode{()} returning \keyword{int}'' and
7189+
\item
7190+
an ``optionally \tcode{noexcept} function of
7191+
\tcode{(\keyword{int}}, pointer to pointer to \tcode{\keyword{char})}
7192+
returning \keyword{int}''
71757193
\end{itemize}
71767194
\indextext{\idxcode{argc}}%
71777195
\indextext{\idxcode{argv}}%
@@ -7489,7 +7507,7 @@
74897507
\indextext{program!termination|(}%
74907508
\indextext{object!destructor static}%
74917509
\indextext{\idxcode{main} function!return from}%
7492-
Constructed objects\iref{dcl.init}
7510+
Constructed complete objects\iref{dcl.init}
74937511
with static storage duration are destroyed
74947512
and functions registered with \tcode{std::atexit}
74957513
are called as part of a call to
@@ -7503,29 +7521,69 @@
75037521
\end{note}
75047522

75057523
\pnum
7506-
Constructed objects with thread storage duration within a given thread
7524+
Constructed complete objects with thread storage duration within a given thread
75077525
are destroyed as a result of returning from the initial function of that thread and as a
75087526
result of that thread calling \tcode{std::exit}.
7509-
The destruction of all constructed objects with thread storage
7510-
duration within that thread strongly happens before destroying
7527+
The destruction of those constructed objects
7528+
is sequenced before releasing the storage for
7529+
any object with thread storage duration within that thread\iref{basic.stc.thread}.
7530+
The destruction of those constructed objects
7531+
strongly happens before destroying
75117532
any object with static storage duration.
75127533

75137534
\pnum
7514-
If the completion of the constructor or dynamic initialization of an object with static
7515-
storage duration strongly happens before that of another, the completion of the destructor
7516-
of the second is sequenced before the initiation of the destructor of the first.
7517-
If the completion of the constructor or dynamic initialization of an object with thread
7518-
storage duration is sequenced before that of another, the completion of the destructor
7519-
of the second is sequenced before the initiation of the destructor of the first.
7535+
The destruction of a complete object with thread storage duration within a given thread
7536+
and having constant destruction\iref{expr.const}
7537+
is sequenced after the destruction of any other complete object
7538+
with thread storage duration within the thread.
7539+
The destruction of a complete object with static storage duration
7540+
and having constant destruction
7541+
is sequenced after the destruction of any other complete object
7542+
with static storage duration
7543+
and after any call to a function passed to \tcode{std::atexit}.
7544+
The sequencing rules in the remainder of this subclause
7545+
apply only to complete objects not having constant destruction.
7546+
7547+
\pnum
7548+
If the deemed construction\iref{dcl.init.general} of a complete object with static
7549+
storage duration strongly happens before that of another, the completion of the destruction
7550+
of the second is sequenced before the initiation of the destruction of the first.
7551+
If the deemed construction of a complete object with thread
7552+
storage duration is sequenced before that of another, the completion of the destruction
7553+
of the second is sequenced before the initiation of the destruction of the first.
75207554
If an object is
75217555
initialized statically, the object is destroyed in the same order as if
7522-
the object was dynamically initialized. For an object of array or class
7523-
type, all subobjects of that object are destroyed before any block
7524-
variable with static storage duration initialized during the construction
7525-
of the subobjects is destroyed.
7556+
the object was dynamically initialized.
75267557
If the destruction of an object with static or thread storage duration
75277558
exits via an exception,
75287559
the function \tcode{std::terminate} is called\iref{except.terminate}.
7560+
\begin{example}
7561+
In the following program,
7562+
the elements of \tcode{a} are destroyed,
7563+
followed by \tcode{dt}, and
7564+
finally by the two \tcode{Btemp} objects:
7565+
\begin{codeblock}
7566+
struct DTemp { ~DTemp(); };
7567+
struct Temp {
7568+
~Temp() {
7569+
static DTemp dt;
7570+
}
7571+
};
7572+
struct BTemp {
7573+
~BTemp();
7574+
};
7575+
struct A {
7576+
const BTemp &tb;
7577+
~A();
7578+
};
7579+
A a[] = { (Temp(), BTemp()), BTemp() };
7580+
7581+
int main() {}
7582+
\end{codeblock}
7583+
If the array \tcode{a} were an object with automatic storage duration,
7584+
the \tcode{Btemp} temporaries would be destroyed
7585+
as each element of the array is destroyed\iref{class.temporary}.
7586+
\end{example}
75297587

75307588
\pnum
75317589
If a function contains a block variable of static or thread storage duration that has been
@@ -7541,12 +7599,13 @@
75417599
\pnum
75427600
\indextext{\idxcode{atexit}}%
75437601
\indexlibraryglobal{atexit}%
7544-
If the completion of the initialization of an object with static storage
7602+
If the deemed construction of a complete object with static storage
75457603
duration strongly happens before a call to \tcode{std::atexit}~(see
75467604
\libheader{cstdlib}, \ref{support.start.term}), the call to the function passed to
7547-
\tcode{std::atexit} is sequenced before the call to the destructor for the object. If a
7548-
call to \tcode{std::atexit} strongly happens before the completion of the initialization of
7549-
an object with static storage duration, the call to the destructor for the
7605+
\tcode{std::atexit} is sequenced before the initiation of the destruction of the object.
7606+
If a call to \tcode{std::atexit} strongly happens before the deemed construction of
7607+
a complete object with static storage duration,
7608+
the completion of the destruction of the
75507609
object is sequenced before the call to the function passed to \tcode{std::atexit}. If a
75517610
call to \tcode{std::atexit} strongly happens before another call to \tcode{std::atexit}, the
75527611
call to the function passed to the second \tcode{std::atexit} call is sequenced before

source/classes.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,8 @@
17041704
and no virtual base classes\iref{class.mi}, and
17051705

17061706
\item
1707-
the constructor selected to copy/move each direct base class subobject is trivial, and
1707+
the constructor selected to copy/move each direct base class subobject
1708+
is a direct member of that base class and is trivial, and
17081709

17091710
\item
17101711
for each non-static data member of
@@ -1986,7 +1987,7 @@
19861987
and no virtual base classes\iref{class.mi}, and
19871988

19881989
\item the assignment operator selected to copy/move each direct
1989-
base class subobject is trivial, and
1990+
base class subobject is a direct member of that base class and is trivial, and
19901991

19911992
\item
19921993
for each non-static data member of
@@ -3356,7 +3357,8 @@
33563357
\indextext{access control!anonymous \tcode{union}}%
33573358
\indextext{restriction!anonymous \tcode{union}}%
33583359
Each \grammarterm{member-declaration} in the \grammarterm{member-specification}
3359-
of an anonymous union shall either define one or more public non-static data members or
3360+
of an anonymous union shall define one or more public non-static data members,
3361+
be an \grammarterm{empty-declaration}, or
33603362
be a \grammarterm{static_assert-declaration}.
33613363
Nested types, anonymous unions, and functions
33623364
shall not be declared within an anonymous union.

source/compatibility.tex

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,6 +3041,33 @@
30413041
(for instance, via the C typedef in \libheaderref{stdbool.h})
30423042
is ill-formed in \Cpp{}.
30433043

3044+
\diffref{expr.unary.op}
3045+
\change
3046+
In certain contexts,
3047+
taking the address of a dereferenced null or past-the-end pointer value
3048+
is well-defined in C (and yields the original pointer value),
3049+
but results in undefined behavior in \Cpp{}.
3050+
\begin{example}
3051+
\begin{codeblock}
3052+
void f() {
3053+
char *p = nullptr;
3054+
char *p2 = &*p; // well-defined in C, undefined behavior in \Cpp{}
3055+
char *p3 = &p[0]; // well-defined in C, undefined behavior in \Cpp{}
3056+
int a[5];
3057+
int *q = &a[5]; // well-defined in C, undefined behavior in \Cpp{}
3058+
}
3059+
\end{codeblock}
3060+
\end{example}
3061+
\rationale
3062+
Consistent treatment of lvalues in \Cpp{}.
3063+
\effect
3064+
Well-formed and well-defined C code exhibits undefined behavior in \Cpp{}.
3065+
\difficulty
3066+
Syntactic transformation to pointer arithmetic
3067+
and possible addition of a check for null pointer values.
3068+
\howwide
3069+
Occasionally.
3070+
30443071
\diffref{expr.sizeof,expr.cast}
30453072
\change
30463073
In \Cpp{}, types can only be defined in declarations, not in expressions.\\
@@ -3165,6 +3192,24 @@
31653192

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

3195+
\diffref{dcl.pre}
3196+
\change
3197+
In \Cpp{}, no declaration of a variable can have \cv{} \tcode{void} type.
3198+
In C, this is allowed, unless the declaration is a definition.
3199+
\begin{example}
3200+
\begin{codeblock}
3201+
extern void x; // valid C, invalid in \Cpp{}
3202+
\end{codeblock}
3203+
\end{example}
3204+
\rationale
3205+
Stricter type checking in \Cpp{}.
3206+
\effect
3207+
Deletion of semantically well-defined feature.
3208+
\difficulty
3209+
Syntactic transformation.
3210+
\howwide
3211+
Seldom.
3212+
31683213
\diffref{dcl.stc}
31693214
\change
31703215
In \Cpp{}, the \keyword{static} or \keyword{extern} specifiers can only be applied to names of objects or functions.\\

0 commit comments

Comments
 (0)