Skip to content

Motions 2019 02 cwg 1 #2736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2802,24 +2802,26 @@
\indextext{object lifetime|(}%
The \defn{lifetime} of an object or reference is a runtime property of the
object or reference.
An object is said to have \defnadj{non-vacuous}{initialization} if it is of a class or
array type and it or one of its subobjects is initialized by a constructor
other than a trivial default constructor. \begin{note} Initialization by a
trivial copy/move constructor is non-vacuous initialization. \end{note}
\indextext{initialization!vacuous}%
A variable is said to have \defn{vacuous initialization}
if it is default-initialized and,
if it is of class type or a (possibly multi-dimensional) array thereof,
that class type has a trivial default constructor.
The lifetime of an object of type \tcode{T} begins when:
\begin{itemize}
\item storage with the proper alignment and size for type \tcode{T} is
obtained, and
\item if the object has non-vacuous initialization, its initialization is complete,
\item storage with the proper alignment and size
for type \tcode{T} is obtained, and
\item its initialization (if any) is complete
(including vacuous initialization)\iref{dcl.init},
\end{itemize}
except that if the object is a union member or subobject thereof,
its lifetime only begins if that union member is the
initialized member in the union~(\ref{dcl.init.aggr}, \ref{class.base.init}),
or as described in \ref{class.union}.
The lifetime of an object \placeholder{o} of type \tcode{T} ends when:
\begin{itemize}
\item if \tcode{T} is a class type with a non-trivial
destructor\iref{class.dtor}, the destructor call starts, or
\item if \tcode{T} is a non-class type, the object is destroyed, or
\item if \tcode{T} is a class type, the destructor call starts, or
\item the storage which the object occupies is released,
or is reused by an object that is not nested within \placeholder{o}\iref{intro.object}.
\end{itemize}
Expand Down Expand Up @@ -5974,26 +5976,25 @@
\indextext{program!termination|(}%
\indextext{object!destructor static}%
\indextext{\idxcode{main} function!return from}%
Destructors\iref{class.dtor} for initialized objects
(that is, objects whose lifetime\iref{basic.life} has begun)
with static storage duration,
and functions registered with \tcode{std::atexit},
Constructed objects\iref{dcl.init}
with static storage duration are destroyed
and functions registered with \tcode{std::atexit}
are called as part of a call to
\indextext{\idxcode{exit}}%
\indexlibrary{\idxcode{exit}}%
\tcode{std::exit}\iref{support.start.term}.
The call to \tcode{std::exit} is sequenced before
the invocations of the destructors and the registered functions.
the destructions and the registered functions.
\begin{note}
Returning from \tcode{main} invokes \tcode{std::exit}\iref{basic.start.main}.
\end{note}

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

\pnum
Expand Down
5 changes: 2 additions & 3 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2120,7 +2120,6 @@
\tcode{virtual}.

\pnum
A destructor is used to destroy objects of its class type.
\indextext{restriction!destructor}%
The address of a destructor shall not be taken.
\indextext{\idxcode{const}!destructor and}%
Expand Down Expand Up @@ -6506,12 +6505,12 @@
\begin{note} There cannot be a move from the exception object because it is
always an lvalue. \end{note}
\end{itemize}
Copy elision is required
Copy elision is not permitted
where an expression is evaluated in a context
requiring a constant expression\iref{expr.const}
and in constant initialization\iref{basic.start.static}.
\begin{note}
Copy elision might not be performed
Copy elision might be performed
if the same expression
is evaluated in another context.
\end{note}
Expand Down
78 changes: 42 additions & 36 deletions source/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@
each of its parameter types shall be a literal type;

\item
its \grammarterm{function-body} shall not contain
its \grammarterm{function-body} shall not enclose\iref{stmt.stmt}
\begin{itemize}
\item an \grammarterm{asm-definition},
\item a \tcode{goto} statement,
Expand All @@ -822,7 +822,7 @@
\end{itemize}
\begin{note}
A \grammarterm{function-body} that is \tcode{= delete} or \tcode{= default}
contains none of the above.
encloses none of the above.
\end{note}
\end{itemize}

Expand Down Expand Up @@ -955,7 +955,7 @@
a call to a constexpr
function can appear in a constant expression\iref{expr.const} and
\item
copy elision is mandatory in a constant expression\iref{class.copy.elision}.
copy elision is not performed in a constant expression\iref{class.copy.elision}.
\end{itemize}

\pnum
Expand Down Expand Up @@ -1310,8 +1310,11 @@
\opt{\tcode{typename}} \opt{\grammarterm{nested-name-specifier}} \grammarterm{template-name}
is a placeholder for
a deduced class type\iref{dcl.type.class.deduct}.
The \grammarterm{template-name} shall name a class template
that is not an injected-class-name.
The \grammarterm{template-name} shall name a class template.
\begin{note}
An injected-class-name is never interpreted as a \grammarterm{template-name}
in contexts where class template argument deduction would be performed\iref{temp.local}.
\end{note}
The other
\grammarterm{simple-type-specifier}{s}
specify either a previously-declared type, a type determined from an
Expand Down Expand Up @@ -4469,13 +4472,18 @@
\pnum
An object whose initialization has completed
is deemed to be constructed,
even if no constructor of the object's class
even if the object is of non-class type or
no constructor of the object's class
is invoked for the initialization.
\begin{note}
Such an object might have been value-initialized
or initialized by aggregate initialization\iref{dcl.init.aggr}
or by an inherited constructor\iref{class.inhctor.init}.
\end{note}
Destroying an object of class type invokes the destructor of the class.
Destroying a scalar type has no effect other than
ending the lifetime of the object\iref{basic.life}.
Destroying an array destroys each element in reverse subscript order.

\pnum
A declaration that specifies the initialization of a variable,
Expand Down Expand Up @@ -4804,7 +4812,7 @@
\end{example}

\pnum
If a reference member is initialized from its default member initializer
If a member has a default member initializer
and a potentially-evaluated subexpression thereof is an aggregate
initialization that would use that default member initializer,
the program is ill-formed.
Expand All @@ -4817,6 +4825,10 @@
const A& a2 { A{} }; // error
};
A a{a,a}; // OK

struct B {
int n = B{}.n; // error
};
\end{codeblock}
\end{example}

Expand Down Expand Up @@ -5166,29 +5178,17 @@
Given types ``\cvqual{cv1} \tcode{T1}'' and ``\cvqual{cv2} \tcode{T2}'',
``\cvqual{cv1} \tcode{T1}'' is \defn{reference-related} to
``\cvqual{cv2} \tcode{T2}'' if
\tcode{T1} is the same type as \tcode{T2}, or
\tcode{T1} is similar\iref{conv.qual} to \tcode{T2}, or
\tcode{T1} is a base class of \tcode{T2}.
``\cvqual{cv1} \tcode{T1}'' is \defn{reference-compatible}
with ``\cvqual{cv2} \tcode{T2}'' if
\begin{itemize}
\item \tcode{T1} is reference-related to \tcode{T2}, or
\item \tcode{T2} is ``\tcode{noexcept} function'' and \tcode{T1} is ``function'',
where the function types are otherwise the same,
\end{itemize}
and
\cvqual{cv1}
is the same cv-qualification as, or greater cv-qualification than,
\cvqual{cv2}.
In all cases where the reference-related or reference-compatible relationship
of two types is used to establish the validity of a reference binding, and
\tcode{T1}
is a base class of
\tcode{T2},
a program that necessitates such a binding is ill-formed if
\tcode{T1}
is an inaccessible\iref{class.access} or ambiguous\iref{class.member.lookup}
base class of
\tcode{T2}.
a prvalue of type ``pointer to \cvqual{cv2} \tcode{T2}'' can be converted to
the type ``pointer to \cvqual{cv1} \tcode{T1}''
via a standard conversion sequence\iref{conv}.
In all cases where the reference-compatible relationship
of two types is used to establish the validity of a reference binding and
the standard conversion sequence would be ill-formed,
a program that necessitates such a binding is ill-formed.

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

\item Otherwise, if \tcode{T} is a reference type, a prvalue of the type
referenced by \tcode{T} is generated.
The prvalue initializes its result object by
copy-list-initialization or direct-list-initialization,
depending on the kind of initialization for the reference.
The prvalue initializes its result object by copy-list-initialization.
The prvalue is then used to direct-initialize the reference.
\begin{note} As usual, the binding will fail and the program is ill-formed if
the reference type is an lvalue reference to a non-const type. \end{note}
Expand All @@ -5606,6 +5604,10 @@
const int& i1 = { 1 }; // OK
const int& i2 = { 1.1 }; // error: narrowing
const int (&iar)[2] = { 1, 2 }; // OK: \tcode{iar} is bound to temporary array

struct A { } a;
struct B { explicit B(const A&); };
const B &b2{a}; // error: cannot copy-list-initialize \tcode{B} temporary from \tcode{A}
\end{codeblock}
\end{example}

Expand Down Expand Up @@ -8780,15 +8782,19 @@

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

\pnum
\begin{note}
For an entity marked \tcode{maybe_unused}, implementations
should not emit a warning that the entity is unused, or
that the entity is used despite the presence of the attribute.
\end{note}
For an entity marked \tcode{maybe_unused},
implementations should not emit a warning
that the entity or its structured bindings (if any)
are used or unused.
For a structured binding declaration not marked \tcode{maybe_unused},
implementations should not emit such a warning unless
all of its structured bindings are unused.

\pnum
A name or entity declared without the \tcode{maybe_unused} attribute
Expand Down
12 changes: 7 additions & 5 deletions source/exceptions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@
\indextext{unwinding!stack}%
As control passes from the point where an exception is thrown
to a handler,
destructors are invoked by a process, specified in this subclause, called
\defn{stack unwinding}.
objects with automatic storage duration are destroyed by a process,
specified in this subclause, called \defn{stack unwinding}.

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

\pnum
The exception specification for an implicitly-declared assignment operator,
Expand Down
24 changes: 16 additions & 8 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@

\pnum
A prvalue of type ``pointer to \cv{} \tcode{D}'', where \tcode{D}
is a class type, can be converted to a prvalue of type ``pointer to
is a complete class type, can be converted to a prvalue of type ``pointer to
\cv{} \tcode{B}'', where \tcode{B} is a base class\iref{class.derived}
of \tcode{D}. If \tcode{B} is an
inaccessible\iref{class.access} or
Expand Down Expand Up @@ -1005,8 +1005,8 @@
A prvalue of type ``pointer to member of \tcode{B} of type \cv{}
\tcode{T}'', where \tcode{B} is a class type, can be converted to
a prvalue of type ``pointer to member of \tcode{D} of type \cv{}
\tcode{T}'', where \tcode{D} is a derived class\iref{class.derived}
of \tcode{B}. If \tcode{B} is an
\tcode{T}'', where \tcode{D} is a complete class derived\iref{class.derived}
from \tcode{B}. If \tcode{B} is an
inaccessible\iref{class.access},
ambiguous\iref{class.member.lookup}, or virtual\iref{class.mi} base
class of \tcode{D}, or a base class of a virtual base class of
Expand Down Expand Up @@ -2201,7 +2201,11 @@

\pnum
A \grammarterm{lambda-expression} appearing in a default argument shall not
implicitly or explicitly capture any entity.
implicitly or explicitly capture any entity,
except for an \grammarterm{init-capture} for which
any full-expression in its \grammarterm{initializer}
satisfies the constraints of an expression appearing in
a default argument\iref{dcl.fct.default}.
\begin{example}
\begin{codeblock}
void f2() {
Expand All @@ -2211,6 +2215,8 @@
void g3(int = ([=]{ return i; })()); // ill-formed
void g4(int = ([=]{ return 0; })()); // OK
void g5(int = ([]{ return sizeof i; })()); // OK
void g6(int = ([x=1]{ return x; })(); // OK
void g7(int = ([x=i]{ return x; })(); // ill-formed
}
\end{codeblock}
\end{example}
Expand Down Expand Up @@ -3713,7 +3719,8 @@
\indextext{cast!derived class}%
A prvalue of type ``pointer to \cvqual{cv1} \tcode{B}'', where \tcode{B}
is a class type, can be converted to a prvalue of type ``pointer to
\cvqual{cv2} \tcode{D}'', where \tcode{D} is a class derived\iref{class.derived}
\cvqual{cv2} \tcode{D}'',
where \tcode{D} is a complete class derived\iref{class.derived}
from \tcode{B},
if \cvqual{cv2} is the same cv-qualification as,
or greater cv-qualification than, \cvqual{cv1}.
Expand All @@ -3732,8 +3739,9 @@
\indextext{cast!pointer-to-member}%
A prvalue of type ``pointer to member of \tcode{D} of type \cvqual{cv1}
\tcode{T}'' can be converted to a prvalue of type ``pointer to member of
\tcode{B} of type \cvqual{cv2} \tcode{T}'', where \tcode{B} is a base
class\iref{class.derived} of \tcode{D},
\tcode{B} of type \cvqual{cv2} \tcode{T}'', where
\tcode{D} is a complete class type and
\tcode{B} is a base class\iref{class.derived} of \tcode{D},
if \cvqual{cv2} is the same cv-qualification
as, or greater cv-qualification than, \cvqual{cv1}.\footnote{Function types
(including those used in pointer-to-member-function
Expand Down Expand Up @@ -6505,7 +6513,7 @@
requirements as detailed in this subclause; other contexts have different
semantics depending on whether or not an expression satisfies these requirements.
Expressions that satisfy these requirements,
assuming that copy elision is performed,
assuming that copy elision\iref{class.copy.elision} is not performed,
are called
\indexdefn{expression!constant}%
\defnx{constant expressions}{constant expression}. \begin{note} Constant expressions can be evaluated
Expand Down
8 changes: 5 additions & 3 deletions source/overloading.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1406,9 +1406,11 @@
with ``\cvqual{cv2} \tcode{T2}'',
are candidate functions. For direct-initialization, those explicit
conversion functions that are not hidden within \tcode{S} and yield
type ``lvalue reference to \cvqual{cv2} \tcode{T2}'' or ``\cvqual{cv2}
\tcode{T2}'' or ``rvalue reference to \cvqual{cv2} \tcode{T2}'',
respectively, where \tcode{T2} is the same type as \tcode{T} or can be
type ``lvalue reference to \cvqual{cv2} \tcode{T2}''
(when initializing an lvalue reference or an rvalue reference to function)
or ``rvalue reference to \cvqual{cv2} \tcode{T2}''
(when initializing an rvalue reference or an lvalue reference to function),
where \tcode{T2} is the same type as \tcode{T} or can be
converted to type \tcode{T} with a qualification
conversion\iref{conv.qual}, are also candidate functions.

Expand Down
Loading