Skip to content

Commit db517f8

Browse files
authored
Merge 2023-11 CWG Motion 1
P3046R0 Core Language Working Group "ready" Issues
2 parents 9961cd4 + 4fb5ad3 commit db517f8

File tree

11 files changed

+342
-126
lines changed

11 files changed

+342
-126
lines changed

source/basic.tex

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,22 @@
10001000
\pnum
10011001
A declaration is \defnx{name-independent}{declaration!name-independent}
10021002
if its name is \tcode{_} (\unicode{005f}{low line}) and it declares
1003+
\begin{itemize}
1004+
\item
10031005
a variable with automatic storage duration,
1004-
a structured binding not inhabiting a namespace scope,
1006+
\item
1007+
a structured binding
1008+
%FIXME: "and" is strange below; maybe reword to something like:
1009+
%FIXME: "that has no \grammarterm{storage-class-specifier} and
1010+
%FIXME: that is not inhabiting a namespace scope,"
1011+
with no \grammarterm{storage-class-specifier} and
1012+
not inhabiting a namespace scope,
1013+
\item
10051014
the variable introduced by an \grammarterm{init-capture}, or
1006-
a non-static data member.
1015+
\item
1016+
%FIXME: "of" is strange below; remove it?
1017+
a non-static data member of other than an anonymous union.
1018+
\end{itemize}
10071019

10081020
\recommended
10091021
Implementations should not emit a warning
@@ -1278,7 +1290,7 @@
12781290
\pnum
12791291
If a declaration
12801292
that is not a name-independent declaration and
1281-
whose target scope is the block scope $S$ of a
1293+
that binds a name in the block scope $S$ of a
12821294
\begin{itemize}
12831295
\item
12841296
\grammarterm{compound-statement} of a \grammarterm{lambda-expression},
@@ -3300,6 +3312,12 @@
33003312
standard-layout type\iref{basic.types.general} shall occupy contiguous bytes of
33013313
storage.
33023314

3315+
\pnum
3316+
An object is a \defnadj{potentially non-unique}{object} if it is
3317+
a string literal object\iref{lex.string},
3318+
the backing array of an initializer list\iref{dcl.init.ref}, or
3319+
a subobject thereof.
3320+
33033321
\pnum
33043322
\indextext{most derived object!bit-field}%
33053323
\indextext{most derived object!zero size subobject}%
@@ -3308,11 +3326,13 @@
33083326
Two objects
33093327
with overlapping lifetimes
33103328
that are not bit-fields
3311-
may have the same address
3312-
if one is nested within the other,
3329+
may have the same address if
3330+
\begin{itemize}
3331+
\item one is nested within the other,
3332+
\item at least one is a subobject of zero size and they are not of similar types\iref{conv.qual},
33133333
or
3314-
if at least one is a subobject of zero size
3315-
and they are of different types;
3334+
\item they are both potentially non-unique objects;
3335+
\end{itemize}
33163336
otherwise, they have distinct addresses
33173337
and occupy disjoint bytes of storage.
33183338
\begin{footnote}
@@ -3326,6 +3346,14 @@
33263346
static const char test1 = 'x';
33273347
static const char test2 = 'x';
33283348
const bool b = &test1 != &test2; // always \tcode{true}
3349+
3350+
static const char (&r) [] = "x";
3351+
static const char *s = "x";
3352+
static std::initializer_list<char> il = { 'x' };
3353+
const bool b2 = r != il.begin(); // unspecified result
3354+
const bool b3 = r != s; // unspecified result
3355+
const bool b4 = il.begin() != &test1; // always \tcode{true}
3356+
const bool b5 = r != &test1; // always \tcode{true}
33293357
\end{codeblock}
33303358
\end{example}
33313359
The address of a non-bit-field subobject of zero size is

source/classes.tex

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,10 @@
796796
\item
797797
corresponding entities have the same alignment requirements\iref{basic.align},
798798
\item
799-
either both entities are declared with
800-
the \tcode{no_unique_address} attribute\iref{dcl.attr.nouniqueaddr}
801-
or neither is, and
799+
if a \grammarterm{has-attribute-expression}\iref{cpp.cond}
800+
is not \tcode{0} for the \tcode{no_unique_address} attribute,
801+
then neither entity is declared with
802+
the \tcode{no_unique_address} attribute\iref{dcl.attr.nouniqueaddr}, and
802803
\item
803804
either both entities are bit-fields with the same width
804805
or neither is a bit-field.
@@ -1095,7 +1096,9 @@
10951096
\begin{itemize}
10961097
\item the function is not deleted,
10971098
\item the associated constraints\iref{temp.constr}, if any, are satisfied, and
1098-
\item no special member function of the same kind is more constrained\iref{temp.constr.order}.
1099+
\item no special member function of the same kind
1100+
whose associated constraints, if any, are satisfied
1101+
is more constrained\iref{temp.constr.order}.
10991102
\end{itemize}
11001103

11011104
\pnum
@@ -1983,9 +1986,8 @@
19831986
shall be
19841987
\keyword{friend},
19851988
\keyword{inline},
1986-
\keyword{virtual},
1987-
\keyword{constexpr}, or
1988-
\keyword{consteval}.
1989+
\keyword{virtual}, or
1990+
\keyword{constexpr}.
19891991

19901992
\pnum
19911993
\indextext{generated destructor|see{destructor, default}}%
@@ -2114,7 +2116,8 @@
21142116
\tcode{X}
21152117
calls the destructors for
21162118
\tcode{X}'s
2117-
direct non-variant non-static data members, the destructors for
2119+
direct non-variant non-static data members other than anonymous unions,
2120+
the destructors for
21182121
\tcode{X}'s
21192122
non-virtual direct base classes and, if
21202123
\tcode{X}
@@ -3155,7 +3158,10 @@
31553158
In an assignment expression of the form \tcode{E1 = E2}
31563159
that uses either the built-in assignment operator\iref{expr.ass}
31573160
or a trivial assignment operator\iref{class.copy.assign},
3158-
for each element \tcode{X} of $S($\tcode{E1}$)$,
3161+
for each element \tcode{X} of $S($\tcode{E1}$)$ and
3162+
each anonymous union member \tcode{X}\iref{class.union.anon} that
3163+
is a member of a union and
3164+
has such an element as an immediate subobject (recursively),
31593165
if modification of \tcode{X} would have undefined behavior under~\ref{basic.life},
31603166
an object of the type of \tcode{X} is implicitly created
31613167
in the nominated storage;
@@ -5818,9 +5824,16 @@
58185824
were used to initialize the \tcode{D} object and
58195825
each base class subobject from which the constructor was inherited,
58205826
except that the \tcode{B} subobject is initialized
5821-
by the invocation of the inherited constructor.
5827+
by the inherited constructor
5828+
if the base class subobject were to be initialized
5829+
as part of the \tcode{D} object\iref{class.base.init}.
5830+
The invocation of the inherited constructor,
5831+
including the evaluation of any arguments,
5832+
is omitted if the \tcode{B} subobject is not to be initialized
5833+
as part of the \tcode{D} object.
58225834
The complete initialization is considered to be a single function call;
5823-
in particular, the initialization of the inherited constructor's parameters
5835+
in particular, unless omitted,
5836+
the initialization of the inherited constructor's parameters
58245837
is sequenced before the initialization of any part of the \tcode{D} object.
58255838
\begin{example}
58265839
\begin{codeblock}
@@ -5870,6 +5883,23 @@
58705883
whenever an object of class \tcode{Log} is destroyed.
58715884
\end{example}
58725885

5886+
\begin{example}
5887+
\begin{codeblock}
5888+
struct V { V() = default; V(int); };
5889+
struct Q { Q(); };
5890+
struct A : virtual V, Q {
5891+
using V::V;
5892+
A() = delete;
5893+
};
5894+
int bar() { return 42; }
5895+
struct B : A {
5896+
B() : A(bar()) {} // OK
5897+
};
5898+
struct C : B {};
5899+
void foo() { C c; } // \tcode{bar} is not invoked, because the \tcode{V} subobject is not initialized as part of \tcode{B}
5900+
\end{codeblock}
5901+
\end{example}
5902+
58735903
\pnum
58745904
If the constructor was inherited from multiple base class subobjects
58755905
of type \tcode{B}, the program is ill-formed.

source/compatibility.tex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,27 @@
18261826
revision of \Cpp{} because \tcode{double} to \tcode{int} is a narrowing
18271827
conversion.
18281828

1829+
\diffref{dcl.link}
1830+
\change
1831+
Names declared in an anonymous namespace
1832+
changed from external linkage to internal linkage;
1833+
language linkage applies to names with external linkage only.
1834+
\rationale
1835+
Alignment with user expectations.
1836+
\effect
1837+
Valid \CppIII{} code may violate the one-definition rule\iref{basic.def.odr}
1838+
in this revision of \Cpp{}.
1839+
For example:
1840+
\begin{codeblock}
1841+
namespace { extern "C" { extern int x; } } // \#1, previously external linkage and C language linkage,
1842+
// now internal linkage and \Cpp{} language linkage
1843+
namespace A { extern "C" int x = 42; } // \#2, external linkage and C language linkage
1844+
int main(void) { return x; }
1845+
\end{codeblock}
1846+
This code is valid in \CppIII{},
1847+
but \tcode{\#2} is not a definition for \tcode{\#1}
1848+
in this revision of \Cpp{}, violating the one-definition rule.
1849+
18291850
\rSec2[diff.cpp03.class]{\ref{class}: classes}
18301851

18311852
\diffref{class.default.ctor,class.dtor,class.copy.ctor,class.copy.assign}

0 commit comments

Comments
 (0)