Skip to content

Commit 089515a

Browse files
authored
Merge 2023-06 CWG Motion 1
P2922R0 Core Language Working Group "ready" Issues
2 parents 9640157 + f1e4e9e commit 089515a

File tree

9 files changed

+294
-172
lines changed

9 files changed

+294
-172
lines changed

source/basic.tex

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,6 +3384,21 @@
33843384
\item the storage which the object occupies is released,
33853385
or is reused by an object that is not nested within \placeholder{o}\iref{intro.object}.
33863386
\end{itemize}
3387+
When evaluating a \grammarterm{new-expression},
3388+
storage is considered reused after it is returned from the allocation function,
3389+
but before the evaluation of the \grammarterm{new-initializer}\iref{expr.new}.
3390+
\begin{example}
3391+
\begin{codeblock}
3392+
struct S {
3393+
int m;
3394+
};
3395+
3396+
void f() {
3397+
S x{1};
3398+
new(&x) S(x.m); // undefined behavior
3399+
}
3400+
\end{codeblock}
3401+
\end{example}
33873402

33883403
\pnum
33893404
\indextext{reference lifetime}%
@@ -4103,6 +4118,9 @@
41034118
at which a given object can be allocated. An object type imposes an alignment
41044119
requirement on every object of that type; stricter alignment can be requested
41054120
using the alignment specifier\iref{dcl.align}.
4121+
Attempting to create an object\iref{intro.object} in storage that
4122+
does not meet the alignment requirements of the object's type
4123+
is undefined behavior.
41064124

41074125
\pnum
41084126
A \defnadj{fundamental}{alignment} is represented by an alignment
@@ -4637,15 +4655,28 @@
46374655
\pnum
46384656
\label{term.object.representation}%
46394657
The \defnx{object representation}{representation!object}
4640-
of an object of type \tcode{T} is the
4658+
of a complete object type \tcode{T} is the
46414659
sequence of \placeholder{N} \tcode{\keyword{unsigned} \keyword{char}} objects taken up
4642-
by the object of type \tcode{T}, where \placeholder{N} equals
4660+
by a non-bit-field complete object of type \tcode{T},
4661+
where \placeholder{N} equals
46434662
\tcode{\keyword{sizeof}(T)}.
46444663
The \defnx{value representation}{representation!value}
4645-
of an object of type \tcode{T} is the set of bits
4664+
of a type \tcode{T} is the set of bits
4665+
in the object representation of \tcode{T}
46464666
that participate in representing a value of type \tcode{T}.
4667+
The object and value representation of
4668+
a non-bit-field complete object of type \tcode{T} are
4669+
the bytes and bits, respectively, of
4670+
the object corresponding to the object and value representation of its type.
4671+
The object representation of a bit-field object is
4672+
the sequence of \placeholder{N} bits taken up by the object,
4673+
where \placeholder{N} is the width of the bit-field\iref{class.bit}.
4674+
The value representation of a bit-field object is
4675+
the set of bits in the object representation that
4676+
participate in representing its value.
46474677
\label{term.padding.bits}%
4648-
Bits in the object representation that are not part of the value representation
4678+
Bits in the object representation of a type or object that are
4679+
not part of the value representation
46494680
are \defn{padding bits}.
46504681
For trivially copyable types, the value representation is
46514682
a set of bits in the object representation that determines a
@@ -5058,6 +5089,22 @@
50585089
the object and value representations and accuracy of operations
50595090
of floating-point types are \impldef{representation of floating-point types}.
50605091

5092+
\pnum
5093+
The minimum range of representable values for a floating-point type is
5094+
the most negative finite floating-point number representable
5095+
in that type through
5096+
the most positive finite floating-point number representable in that type.
5097+
In addition, if negative infinity is representable in a type,
5098+
the range of that type is extended to all negative real numbers;
5099+
likewise, if positive infinity is representable in a type,
5100+
the range of that type is extended to all positive real numbers.
5101+
\begin{note}
5102+
Since negative and positive infinity are representable
5103+
in ISO/IEC/IEEE 60559 formats,
5104+
all real numbers lie within the range of representable values of
5105+
a floating-point type adhering to ISO/IEC/IEEE 60559.
5106+
\end{note}
5107+
50615108
\pnum
50625109
Integral and floating-point types are collectively
50635110
termed \defnx{arithmetic types}{type!arithmetic}.

source/classes.tex

Lines changed: 43 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,38 +1247,34 @@
12471247
\pnum
12481248
A defaulted default constructor for class \tcode{X} is defined as deleted if:
12491249
\begin{itemize}
1250-
\item \tcode{X} is a union that has a variant member
1251-
with a non-trivial default constructor and
1252-
no variant member of \tcode{X} has a default member initializer,
1253-
1254-
\item \tcode{X} is a non-union class that has a variant member \tcode{M}
1255-
with a non-trivial default constructor and
1256-
no variant member of the anonymous union containing \tcode{M}
1257-
has a default member initializer,
1258-
12591250
\item any non-static data member with no default member initializer\iref{class.mem} is
12601251
of reference type,
12611252

1262-
\item any non-variant non-static data member of const-qualified type (or array
1263-
thereof) with no \grammarterm{brace-or-equal-initializer}
1253+
\item any non-variant non-static data member of const-qualified type
1254+
(or possibly multi-dimensional array thereof)
1255+
with no \grammarterm{brace-or-equal-initializer}
12641256
is not const-default-constructible\iref{dcl.init},
12651257

12661258
\item \tcode{X} is a union and all of its variant members are of const-qualified
1267-
type (or array thereof),
1259+
type (or possibly multi-dimensional array thereof),
12681260

12691261
\item \tcode{X} is a non-union class and all members of any anonymous union member are
1270-
of const-qualified type (or array thereof),
1262+
of const-qualified type (or possibly multi-dimensional array thereof),
12711263

12721264
\item any potentially constructed subobject, except for a non-static data member
1273-
with a \grammarterm{brace-or-equal-initializer}, has
1274-
class type \tcode{M} (or array thereof) and either \tcode{M}
1275-
has no default constructor or overload resolution\iref{over.match}
1276-
as applied to find \tcode{M}'s corresponding
1277-
constructor results in an ambiguity or in a function that is deleted or
1278-
inaccessible from the defaulted default constructor, or
1279-
1280-
\item any potentially constructed subobject has a type
1281-
with a destructor that is deleted or inaccessible from the defaulted default
1265+
with a \grammarterm{brace-or-equal-initializer}
1266+
or a variant member of a union where another non-static data member
1267+
has a \grammarterm{brace-or-equal-initializer},
1268+
has class type \tcode{M} (or possibly multi-dimensional array thereof)
1269+
and overload resolution\iref{over.match}
1270+
as applied to find \tcode{M}'s corresponding constructor
1271+
either does not result in a usable candidate\iref{over.match.general}
1272+
or, in the case of a variant member, selects a non-trivial function, or
1273+
1274+
\item any potentially constructed subobject has
1275+
class type \tcode{M} (or possibly multi-dimensional array thereof) and
1276+
\tcode{M} has
1277+
a destructor that is deleted or inaccessible from the defaulted default
12821278
constructor.
12831279
\end{itemize}
12841280

@@ -1543,18 +1539,16 @@
15431539
\tcode{X} is defined as deleted\iref{dcl.fct.def.delete} if \tcode{X} has:
15441540
\begin{itemize}
15451541
\item a potentially constructed subobject of type
1546-
\tcode{M} (or array thereof) that cannot be copied/moved because
1542+
\tcode{M} (or possibly multi-dimensional array thereof) for which
15471543
overload resolution\iref{over.match}, as applied to find
1548-
\tcode{M}'s
1549-
corresponding constructor, results in an ambiguity or
1550-
a function that is deleted or inaccessible from the
1551-
defaulted constructor,
1552-
1553-
\item a variant member whose corresponding constructor
1554-
as selected by overload resolution is non-trivial,
1555-
1556-
\item any potentially constructed subobject of a type
1557-
with a destructor that is deleted or inaccessible from the defaulted
1544+
\tcode{M}'s corresponding constructor,
1545+
either does not result in a usable candidate\iref{over.match.general} or,
1546+
in the case of a variant member, selects a non-trivial function,
1547+
1548+
\item any potentially constructed subobject of
1549+
class type \tcode{M} (or possibly multi-dimensional array thereof)
1550+
where \tcode{M} has
1551+
a destructor that is deleted or inaccessible from the defaulted
15581552
constructor, or,
15591553

15601554
\item for the copy constructor, a non-static data member of rvalue reference type.
@@ -1823,21 +1817,19 @@
18231817
A defaulted copy/move assignment operator for
18241818
class \tcode{X} is defined as deleted if \tcode{X} has:
18251819
\begin{itemize}
1826-
\item a variant member with a non-trivial corresponding assignment operator and
1827-
\tcode{X} is a union-like class, or
1828-
18291820
\item a non-static data member of \keyword{const} non-class
1830-
type (or array thereof), or
1821+
type (or possibly multi-dimensional array thereof), or
18311822

18321823
\item a non-static data member of reference type, or
18331824

18341825
\item a direct non-static data member of class type \tcode{M}
1835-
(or array thereof) or a direct base class \tcode{M}
1826+
(or possibly multi-dimensional array thereof) or
1827+
a direct base class \tcode{M}
18361828
that cannot be copied/moved because overload resolution
18371829
\iref{over.match}, as applied to find \tcode{M}'s corresponding
1838-
assignment operator, results in an ambiguity or
1839-
a function that is deleted or inaccessible from the
1840-
defaulted assignment operator.
1830+
assignment operator,
1831+
either does not result in a usable candidate\iref{over.match.general} or,
1832+
in the case of a variant member, selects a non-trivial function.
18411833
\end{itemize}
18421834

18431835
\begin{note}
@@ -2070,13 +2062,11 @@
20702062
A defaulted destructor for a class
20712063
\tcode{X} is defined as deleted if:
20722064
\begin{itemize}
2073-
\item \tcode{X} is a union-like class that has a variant
2074-
member with a non-trivial destructor,
2075-
20762065
\item any potentially constructed subobject has class type
2077-
\tcode{M} (or array thereof) and
2078-
\tcode{M} has a deleted destructor or a destructor
2079-
that is inaccessible from the defaulted destructor,
2066+
\tcode{M} (or possibly multi-dimensional array thereof) and
2067+
\tcode{M} has a destructor that is deleted or
2068+
is inaccessible from the defaulted destructor or,
2069+
in the case of a variant member, is non-trivial,
20802070

20812071
\item or, for a virtual destructor, lookup of the non-array deallocation
20822072
function results in an ambiguity or in a function that is deleted or
@@ -2489,17 +2479,16 @@
24892479
returning \grammarterm{conversion-type-id}''.
24902480

24912481
\pnum
2492-
A conversion function is never used to convert a (possibly cv-qualified) object
2493-
to the (possibly cv-qualified) same object type (or a reference to it),
2494-
to a (possibly cv-qualified) base class of that type (or a reference to it),
2482+
\begin{note}
2483+
A conversion function is never invoked for
2484+
implicit or explicit conversions of an object
2485+
to the same object type (or a reference to it),
2486+
to a base class of that type (or a reference to it),
24952487
or to \cv{}~\keyword{void}.
2496-
\begin{footnote}
2497-
These conversions are considered
2498-
as standard conversions for the purposes of overload resolution\iref{over.best.ics,over.ics.ref} and therefore initialization\iref{dcl.init} and explicit casts\iref{expr.static.cast}. A conversion to \keyword{void} does not invoke any conversion function\iref{expr.static.cast}.
24992488
Even though never directly called to perform a conversion,
25002489
such conversion functions can be declared and can potentially
25012490
be reached through a call to a virtual conversion function in a base class.
2502-
\end{footnote}
2491+
\end{note}
25032492
\begin{example}
25042493
\begin{codeblock}
25052494
struct X {

source/declarations.tex

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@
22722272
\tcode{typeid},
22732273
the name of a type shall be specified.
22742274
This can be done with a
2275-
\grammarterm{type-id},
2275+
\grammarterm{type-id} or \grammarterm{new-type-id}\iref{expr.new},
22762276
which is syntactically a declaration for a variable or function
22772277
of that type that omits the name of the entity.
22782278

@@ -2859,7 +2859,7 @@
28592859
A reference can be thought of as a name of an object.
28602860
\end{note}
28612861
\indextext{\idxcode{void\&}}%
2862-
A declarator that specifies the type
2862+
Forming the type
28632863
``reference to \cv{}~\keyword{void}''
28642864
is ill-formed.
28652865

@@ -4075,7 +4075,7 @@
40754075
\end{note}
40764076

40774077
\pnum
4078-
Except for member functions of class templates, the
4078+
Except for member functions of templated classes, the
40794079
default arguments in a member function definition that appears
40804080
outside of the class definition
40814081
are added to the set of default arguments provided by the
@@ -4084,9 +4084,9 @@
40844084
copy or move constructor\iref{class.copy.ctor}, or
40854085
copy or move assignment operator\iref{class.copy.assign}
40864086
is so declared.
4087-
Default arguments for a member function of a class template
4087+
Default arguments for a member function of a templated class
40884088
shall be specified on the initial declaration of the member
4089-
function within the class template.
4089+
function within the templated class.
40904090
\begin{example}
40914091
\begin{codeblock}
40924092
class C {
@@ -4489,7 +4489,7 @@
44894489
If no initializer is specified for an object, the object is default-initialized.
44904490

44914491
\pnum
4492-
If the entity being initialized does not have class type, the
4492+
If the entity being initialized does not have class or array type, the
44934493
\grammarterm{expression-list} in a
44944494
parenthesized initializer shall be a single expression.
44954495

@@ -4696,8 +4696,9 @@
46964696
\item
46974697
Otherwise, the initial value of the object being initialized is
46984698
the (possibly converted) value of the initializer expression.
4699-
A standard conversion sequence\iref{conv} will be used, if necessary,
4700-
to convert the initializer expression to the cv-unqualified version of
4699+
A standard conversion sequence\iref{conv} is used
4700+
to convert the initializer expression to
4701+
a prvalue of the cv-unqualified version of
47014702
the destination type;
47024703
no user-defined conversions are considered.
47034704
If the conversion cannot
@@ -5738,7 +5739,8 @@
57385739
\begin{itemize}
57395740
\item
57405741
If the \grammarterm{braced-init-list}
5741-
contains a \grammarterm{designated-initializer-list},
5742+
contains a \grammarterm{designated-initializer-list} and
5743+
\tcode{T} is not a reference type,
57425744
\tcode{T} shall be an aggregate class.
57435745
The ordered \grammarterm{identifier}{s}
57445746
in the \grammarterm{designator}{s}
@@ -5862,7 +5864,9 @@
58625864
\end{example}
58635865

58645866
\item Otherwise, if
5865-
the initializer list has a single element of type \tcode{E} and either
5867+
the initializer list
5868+
is not a \grammarterm{designated-initializer-list} and
5869+
has a single element of type \tcode{E} and either
58665870
\tcode{T} is not a reference type or its referenced type is
58675871
reference-related to \tcode{E}, the object or reference is initialized
58685872
from that element (by copy-initialization for copy-list-initialization,
@@ -5907,6 +5911,9 @@
59075911
struct A { } a;
59085912
struct B { explicit B(const A&); };
59095913
const B& b2{a}; // error: cannot copy-list-initialize \tcode{B} temporary from \tcode{A}
5914+
5915+
struct C { int x; };
5916+
C&& c = { .x = 1 }; // OK
59105917
\end{codeblock}
59115918
\end{example}
59125919

@@ -7902,6 +7909,22 @@
79027909
\pnum
79037910
If a declaration is named by two \grammarterm{using-declarator}s
79047911
that inhabit the same class scope, the program is ill-formed.
7912+
\begin{example}
7913+
\begin{codeblock}
7914+
struct C {
7915+
int i;
7916+
};
7917+
7918+
struct D1 : C { };
7919+
struct D2 : C { };
7920+
7921+
struct D3 : D1, D2 {
7922+
using D1::i; // OK, equivalent to \tcode{using C::i}
7923+
using D1::i; // error: duplicate
7924+
using D2::i; // error: duplicate, also names \tcode{C::i}
7925+
};
7926+
\end{codeblock}
7927+
\end{example}
79057928

79067929
\pnum
79077930
\begin{note}
@@ -7984,6 +8007,7 @@
79848007
using A::h; // error: conflicts
79858008
using B::x;
79868009
using A::x; // OK, hides \tcode{struct B::x}
8010+
using A::x; // OK, does not conflict with previous \tcode{using A::x}
79878011
x = 99; // assigns to \tcode{A::x}
79888012
struct x x1; // \tcode{x1} has class type \tcode{B::x}
79898013
}

source/exceptions.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,14 @@
257257

258258
\pnum
259259
Throwing an exception
260-
copy-initializes\iref{dcl.init,class.copy.ctor} a temporary object,
260+
initializes a temporary object,
261261
called the
262262
\defnx{exception object}{exception handling!exception object}.
263263
If the type of the exception object would be
264-
an incomplete type,
264+
an incomplete type\iref{basic.types.general},
265265
an abstract class type\iref{class.abstract},
266-
or a pointer to an incomplete type other than \cv{}~\keyword{void}
266+
or a pointer to an incomplete type other than
267+
\cv{}~\keyword{void}\iref{basic.compound}
267268
the program is ill-formed.
268269

269270
\pnum

0 commit comments

Comments
 (0)