Skip to content

Commit 0621b29

Browse files
authored
Merge 2019-02 CWG Motion 1
P1358R0 Core Language Working Group "ready" Issues (Kona 2019) After consulting with CWG, the resolution for CWG2331 was not applied and has been returned to CWG for reconsideration. Fixes #2681.
2 parents 6f34b05 + 27f5ad5 commit 0621b29

File tree

8 files changed

+187
-98
lines changed

8 files changed

+187
-98
lines changed

source/basic.tex

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,24 +2802,26 @@
28022802
\indextext{object lifetime|(}%
28032803
The \defn{lifetime} of an object or reference is a runtime property of the
28042804
object or reference.
2805-
An object is said to have \defnadj{non-vacuous}{initialization} if it is of a class or
2806-
array type and it or one of its subobjects is initialized by a constructor
2807-
other than a trivial default constructor. \begin{note} Initialization by a
2808-
trivial copy/move constructor is non-vacuous initialization. \end{note}
2805+
\indextext{initialization!vacuous}%
2806+
A variable is said to have \defn{vacuous initialization}
2807+
if it is default-initialized and,
2808+
if it is of class type or a (possibly multi-dimensional) array thereof,
2809+
that class type has a trivial default constructor.
28092810
The lifetime of an object of type \tcode{T} begins when:
28102811
\begin{itemize}
2811-
\item storage with the proper alignment and size for type \tcode{T} is
2812-
obtained, and
2813-
\item if the object has non-vacuous initialization, its initialization is complete,
2812+
\item storage with the proper alignment and size
2813+
for type \tcode{T} is obtained, and
2814+
\item its initialization (if any) is complete
2815+
(including vacuous initialization)\iref{dcl.init},
28142816
\end{itemize}
28152817
except that if the object is a union member or subobject thereof,
28162818
its lifetime only begins if that union member is the
28172819
initialized member in the union~(\ref{dcl.init.aggr}, \ref{class.base.init}),
28182820
or as described in \ref{class.union}.
28192821
The lifetime of an object \placeholder{o} of type \tcode{T} ends when:
28202822
\begin{itemize}
2821-
\item if \tcode{T} is a class type with a non-trivial
2822-
destructor\iref{class.dtor}, the destructor call starts, or
2823+
\item if \tcode{T} is a non-class type, the object is destroyed, or
2824+
\item if \tcode{T} is a class type, the destructor call starts, or
28232825
\item the storage which the object occupies is released,
28242826
or is reused by an object that is not nested within \placeholder{o}\iref{intro.object}.
28252827
\end{itemize}
@@ -5974,26 +5976,25 @@
59745976
\indextext{program!termination|(}%
59755977
\indextext{object!destructor static}%
59765978
\indextext{\idxcode{main} function!return from}%
5977-
Destructors\iref{class.dtor} for initialized objects
5978-
(that is, objects whose lifetime\iref{basic.life} has begun)
5979-
with static storage duration,
5980-
and functions registered with \tcode{std::atexit},
5979+
Constructed objects\iref{dcl.init}
5980+
with static storage duration are destroyed
5981+
and functions registered with \tcode{std::atexit}
59815982
are called as part of a call to
59825983
\indextext{\idxcode{exit}}%
59835984
\indexlibrary{\idxcode{exit}}%
59845985
\tcode{std::exit}\iref{support.start.term}.
59855986
The call to \tcode{std::exit} is sequenced before
5986-
the invocations of the destructors and the registered functions.
5987+
the destructions and the registered functions.
59875988
\begin{note}
59885989
Returning from \tcode{main} invokes \tcode{std::exit}\iref{basic.start.main}.
59895990
\end{note}
59905991

59915992
\pnum
5992-
Destructors for initialized objects with thread storage duration within a given thread
5993-
are called as a result of returning from the initial function of that thread and as a
5993+
Constructed objects with thread storage duration within a given thread
5994+
are destroyed as a result of returning from the initial function of that thread and as a
59945995
result of that thread calling \tcode{std::exit}.
5995-
The completions of the destructors for all initialized objects with thread storage
5996-
duration within that thread strongly happen before the initiation of the destructors of
5996+
The destruction of all constructed objects with thread storage
5997+
duration within that thread strongly happens before destroying
59975998
any object with static storage duration.
59985999

59996000
\pnum

source/classes.tex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,6 @@
21202120
\tcode{virtual}.
21212121

21222122
\pnum
2123-
A destructor is used to destroy objects of its class type.
21242123
\indextext{restriction!destructor}%
21252124
The address of a destructor shall not be taken.
21262125
\indextext{\idxcode{const}!destructor and}%
@@ -6506,12 +6505,12 @@
65066505
\begin{note} There cannot be a move from the exception object because it is
65076506
always an lvalue. \end{note}
65086507
\end{itemize}
6509-
Copy elision is required
6508+
Copy elision is not permitted
65106509
where an expression is evaluated in a context
65116510
requiring a constant expression\iref{expr.const}
65126511
and in constant initialization\iref{basic.start.static}.
65136512
\begin{note}
6514-
Copy elision might not be performed
6513+
Copy elision might be performed
65156514
if the same expression
65166515
is evaluated in another context.
65176516
\end{note}

source/declarations.tex

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@
810810
each of its parameter types shall be a literal type;
811811

812812
\item
813-
its \grammarterm{function-body} shall not contain
813+
its \grammarterm{function-body} shall not enclose\iref{stmt.stmt}
814814
\begin{itemize}
815815
\item an \grammarterm{asm-definition},
816816
\item a \tcode{goto} statement,
@@ -822,7 +822,7 @@
822822
\end{itemize}
823823
\begin{note}
824824
A \grammarterm{function-body} that is \tcode{= delete} or \tcode{= default}
825-
contains none of the above.
825+
encloses none of the above.
826826
\end{note}
827827
\end{itemize}
828828

@@ -955,7 +955,7 @@
955955
a call to a constexpr
956956
function can appear in a constant expression\iref{expr.const} and
957957
\item
958-
copy elision is mandatory in a constant expression\iref{class.copy.elision}.
958+
copy elision is not performed in a constant expression\iref{class.copy.elision}.
959959
\end{itemize}
960960

961961
\pnum
@@ -1310,8 +1310,11 @@
13101310
\opt{\tcode{typename}} \opt{\grammarterm{nested-name-specifier}} \grammarterm{template-name}
13111311
is a placeholder for
13121312
a deduced class type\iref{dcl.type.class.deduct}.
1313-
The \grammarterm{template-name} shall name a class template
1314-
that is not an injected-class-name.
1313+
The \grammarterm{template-name} shall name a class template.
1314+
\begin{note}
1315+
An injected-class-name is never interpreted as a \grammarterm{template-name}
1316+
in contexts where class template argument deduction would be performed\iref{temp.local}.
1317+
\end{note}
13151318
The other
13161319
\grammarterm{simple-type-specifier}{s}
13171320
specify either a previously-declared type, a type determined from an
@@ -4469,13 +4472,18 @@
44694472
\pnum
44704473
An object whose initialization has completed
44714474
is deemed to be constructed,
4472-
even if no constructor of the object's class
4475+
even if the object is of non-class type or
4476+
no constructor of the object's class
44734477
is invoked for the initialization.
44744478
\begin{note}
44754479
Such an object might have been value-initialized
44764480
or initialized by aggregate initialization\iref{dcl.init.aggr}
44774481
or by an inherited constructor\iref{class.inhctor.init}.
44784482
\end{note}
4483+
Destroying an object of class type invokes the destructor of the class.
4484+
Destroying a scalar type has no effect other than
4485+
ending the lifetime of the object\iref{basic.life}.
4486+
Destroying an array destroys each element in reverse subscript order.
44794487

44804488
\pnum
44814489
A declaration that specifies the initialization of a variable,
@@ -4804,7 +4812,7 @@
48044812
\end{example}
48054813

48064814
\pnum
4807-
If a reference member is initialized from its default member initializer
4815+
If a member has a default member initializer
48084816
and a potentially-evaluated subexpression thereof is an aggregate
48094817
initialization that would use that default member initializer,
48104818
the program is ill-formed.
@@ -4817,6 +4825,10 @@
48174825
const A& a2 { A{} }; // error
48184826
};
48194827
A a{a,a}; // OK
4828+
4829+
struct B {
4830+
int n = B{}.n; // error
4831+
};
48204832
\end{codeblock}
48214833
\end{example}
48224834

@@ -5166,29 +5178,17 @@
51665178
Given types ``\cvqual{cv1} \tcode{T1}'' and ``\cvqual{cv2} \tcode{T2}'',
51675179
``\cvqual{cv1} \tcode{T1}'' is \defn{reference-related} to
51685180
``\cvqual{cv2} \tcode{T2}'' if
5169-
\tcode{T1} is the same type as \tcode{T2}, or
5181+
\tcode{T1} is similar\iref{conv.qual} to \tcode{T2}, or
51705182
\tcode{T1} is a base class of \tcode{T2}.
51715183
``\cvqual{cv1} \tcode{T1}'' is \defn{reference-compatible}
51725184
with ``\cvqual{cv2} \tcode{T2}'' if
5173-
\begin{itemize}
5174-
\item \tcode{T1} is reference-related to \tcode{T2}, or
5175-
\item \tcode{T2} is ``\tcode{noexcept} function'' and \tcode{T1} is ``function'',
5176-
where the function types are otherwise the same,
5177-
\end{itemize}
5178-
and
5179-
\cvqual{cv1}
5180-
is the same cv-qualification as, or greater cv-qualification than,
5181-
\cvqual{cv2}.
5182-
In all cases where the reference-related or reference-compatible relationship
5183-
of two types is used to establish the validity of a reference binding, and
5184-
\tcode{T1}
5185-
is a base class of
5186-
\tcode{T2},
5187-
a program that necessitates such a binding is ill-formed if
5188-
\tcode{T1}
5189-
is an inaccessible\iref{class.access} or ambiguous\iref{class.member.lookup}
5190-
base class of
5191-
\tcode{T2}.
5185+
a prvalue of type ``pointer to \cvqual{cv2} \tcode{T2}'' can be converted to
5186+
the type ``pointer to \cvqual{cv1} \tcode{T1}''
5187+
via a standard conversion sequence\iref{conv}.
5188+
In all cases where the reference-compatible relationship
5189+
of two types is used to establish the validity of a reference binding and
5190+
the standard conversion sequence would be ill-formed,
5191+
a program that necessitates such a binding is ill-formed.
51925192

51935193
\pnum
51945194
A reference to type ``\cvqual{cv1} \tcode{T1}'' is initialized by
@@ -5586,9 +5586,7 @@
55865586

55875587
\item Otherwise, if \tcode{T} is a reference type, a prvalue of the type
55885588
referenced by \tcode{T} is generated.
5589-
The prvalue initializes its result object by
5590-
copy-list-initialization or direct-list-initialization,
5591-
depending on the kind of initialization for the reference.
5589+
The prvalue initializes its result object by copy-list-initialization.
55925590
The prvalue is then used to direct-initialize the reference.
55935591
\begin{note} As usual, the binding will fail and the program is ill-formed if
55945592
the reference type is an lvalue reference to a non-const type. \end{note}
@@ -5606,6 +5604,10 @@
56065604
const int& i1 = { 1 }; // OK
56075605
const int& i2 = { 1.1 }; // error: narrowing
56085606
const int (&iar)[2] = { 1, 2 }; // OK: \tcode{iar} is bound to temporary array
5607+
5608+
struct A { } a;
5609+
struct B { explicit B(const A&); };
5610+
const B &b2{a}; // error: cannot copy-list-initialize \tcode{B} temporary from \tcode{A}
56095611
\end{codeblock}
56105612
\end{example}
56115613

@@ -8780,15 +8782,19 @@
87808782

87818783
\pnum
87828784
The attribute may be applied to the declaration of a class,
8783-
a \grammarterm{typedef-name}, a variable, a non-static data member,
8785+
a \grammarterm{typedef-name},
8786+
a variable (including a structured binding declaration),
8787+
a non-static data member,
87848788
a function, an enumeration, or an enumerator.
87858789

87868790
\pnum
8787-
\begin{note}
8788-
For an entity marked \tcode{maybe_unused}, implementations
8789-
should not emit a warning that the entity is unused, or
8790-
that the entity is used despite the presence of the attribute.
8791-
\end{note}
8791+
For an entity marked \tcode{maybe_unused},
8792+
implementations should not emit a warning
8793+
that the entity or its structured bindings (if any)
8794+
are used or unused.
8795+
For a structured binding declaration not marked \tcode{maybe_unused},
8796+
implementations should not emit such a warning unless
8797+
all of its structured bindings are unused.
87928798

87938799
\pnum
87948800
A name or entity declared without the \tcode{maybe_unused} attribute

source/exceptions.tex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@
365365
\indextext{unwinding!stack}%
366366
As control passes from the point where an exception is thrown
367367
to a handler,
368-
destructors are invoked by a process, specified in this subclause, called
369-
\defn{stack unwinding}.
368+
objects with automatic storage duration are destroyed by a process,
369+
specified in this subclause, called \defn{stack unwinding}.
370370

371371
\pnum
372-
The destructor is invoked for each automatic object of class type constructed,
373-
but not yet destroyed,
372+
Each object with automatic storage duration is destroyed if it has been
373+
constructed, but not yet destroyed,
374374
since the try block was entered.
375375
If an exception is thrown during the destruction of temporaries or
376376
local variables for a \tcode{return} statement\iref{stmt.return},
@@ -882,7 +882,9 @@
882882
is potentially-throwing if and only if
883883
any of the destructors
884884
for any of its potentially constructed subobjects
885-
is potentially throwing.
885+
is potentially-throwing or
886+
the destructor is virtual and the destructor of any virtual base class
887+
is potentially-throwing.
886888

887889
\pnum
888890
The exception specification for an implicitly-declared assignment operator,

source/expressions.tex

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@
973973

974974
\pnum
975975
A prvalue of type ``pointer to \cv{} \tcode{D}'', where \tcode{D}
976-
is a class type, can be converted to a prvalue of type ``pointer to
976+
is a complete class type, can be converted to a prvalue of type ``pointer to
977977
\cv{} \tcode{B}'', where \tcode{B} is a base class\iref{class.derived}
978978
of \tcode{D}. If \tcode{B} is an
979979
inaccessible\iref{class.access} or
@@ -1005,8 +1005,8 @@
10051005
A prvalue of type ``pointer to member of \tcode{B} of type \cv{}
10061006
\tcode{T}'', where \tcode{B} is a class type, can be converted to
10071007
a prvalue of type ``pointer to member of \tcode{D} of type \cv{}
1008-
\tcode{T}'', where \tcode{D} is a derived class\iref{class.derived}
1009-
of \tcode{B}. If \tcode{B} is an
1008+
\tcode{T}'', where \tcode{D} is a complete class derived\iref{class.derived}
1009+
from \tcode{B}. If \tcode{B} is an
10101010
inaccessible\iref{class.access},
10111011
ambiguous\iref{class.member.lookup}, or virtual\iref{class.mi} base
10121012
class of \tcode{D}, or a base class of a virtual base class of
@@ -2201,7 +2201,11 @@
22012201

22022202
\pnum
22032203
A \grammarterm{lambda-expression} appearing in a default argument shall not
2204-
implicitly or explicitly capture any entity.
2204+
implicitly or explicitly capture any entity,
2205+
except for an \grammarterm{init-capture} for which
2206+
any full-expression in its \grammarterm{initializer}
2207+
satisfies the constraints of an expression appearing in
2208+
a default argument\iref{dcl.fct.default}.
22052209
\begin{example}
22062210
\begin{codeblock}
22072211
void f2() {
@@ -2211,6 +2215,8 @@
22112215
void g3(int = ([=]{ return i; })()); // ill-formed
22122216
void g4(int = ([=]{ return 0; })()); // OK
22132217
void g5(int = ([]{ return sizeof i; })()); // OK
2218+
void g6(int = ([x=1]{ return x; })(); // OK
2219+
void g7(int = ([x=i]{ return x; })(); // ill-formed
22142220
}
22152221
\end{codeblock}
22162222
\end{example}
@@ -3713,7 +3719,8 @@
37133719
\indextext{cast!derived class}%
37143720
A prvalue of type ``pointer to \cvqual{cv1} \tcode{B}'', where \tcode{B}
37153721
is a class type, can be converted to a prvalue of type ``pointer to
3716-
\cvqual{cv2} \tcode{D}'', where \tcode{D} is a class derived\iref{class.derived}
3722+
\cvqual{cv2} \tcode{D}'',
3723+
where \tcode{D} is a complete class derived\iref{class.derived}
37173724
from \tcode{B},
37183725
if \cvqual{cv2} is the same cv-qualification as,
37193726
or greater cv-qualification than, \cvqual{cv1}.
@@ -3732,8 +3739,9 @@
37323739
\indextext{cast!pointer-to-member}%
37333740
A prvalue of type ``pointer to member of \tcode{D} of type \cvqual{cv1}
37343741
\tcode{T}'' can be converted to a prvalue of type ``pointer to member of
3735-
\tcode{B} of type \cvqual{cv2} \tcode{T}'', where \tcode{B} is a base
3736-
class\iref{class.derived} of \tcode{D},
3742+
\tcode{B} of type \cvqual{cv2} \tcode{T}'', where
3743+
\tcode{D} is a complete class type and
3744+
\tcode{B} is a base class\iref{class.derived} of \tcode{D},
37373745
if \cvqual{cv2} is the same cv-qualification
37383746
as, or greater cv-qualification than, \cvqual{cv1}.\footnote{Function types
37393747
(including those used in pointer-to-member-function
@@ -6505,7 +6513,7 @@
65056513
requirements as detailed in this subclause; other contexts have different
65066514
semantics depending on whether or not an expression satisfies these requirements.
65076515
Expressions that satisfy these requirements,
6508-
assuming that copy elision is performed,
6516+
assuming that copy elision\iref{class.copy.elision} is not performed,
65096517
are called
65106518
\indexdefn{expression!constant}%
65116519
\defnx{constant expressions}{constant expression}. \begin{note} Constant expressions can be evaluated

source/overloading.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,9 +1406,11 @@
14061406
with ``\cvqual{cv2} \tcode{T2}'',
14071407
are candidate functions. For direct-initialization, those explicit
14081408
conversion functions that are not hidden within \tcode{S} and yield
1409-
type ``lvalue reference to \cvqual{cv2} \tcode{T2}'' or ``\cvqual{cv2}
1410-
\tcode{T2}'' or ``rvalue reference to \cvqual{cv2} \tcode{T2}'',
1411-
respectively, where \tcode{T2} is the same type as \tcode{T} or can be
1409+
type ``lvalue reference to \cvqual{cv2} \tcode{T2}''
1410+
(when initializing an lvalue reference or an rvalue reference to function)
1411+
or ``rvalue reference to \cvqual{cv2} \tcode{T2}''
1412+
(when initializing an rvalue reference or an lvalue reference to function),
1413+
where \tcode{T2} is the same type as \tcode{T} or can be
14121414
converted to type \tcode{T} with a qualification
14131415
conversion\iref{conv.qual}, are also candidate functions.
14141416

0 commit comments

Comments
 (0)