Skip to content

Commit 0b326cd

Browse files
authored
Merge 2019-02 CWG Motion 2
P1359R0 Core Language Working Group "tentatively ready" Issues (Kona 2019) Fixes #2682.
2 parents ac732bf + 8bc56e3 commit 0b326cd

File tree

7 files changed

+168
-132
lines changed

7 files changed

+168
-132
lines changed

source/basic.tex

Lines changed: 82 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@
279279

280280
\pnum
281281
\indextext{expression!potentially evaluated}%
282-
An expression is \defn{potentially evaluated} unless it is an
283-
unevaluated operand\iref{expr.prop} or a subexpression thereof.
282+
An expression or conversion is \defn{potentially evaluated} unless it is
283+
an unevaluated operand\iref{expr.prop},
284+
a subexpression thereof, or
285+
a conversion in an initialization or conversion sequence in such a context.
284286
The set of \defn{potential results} of an expression \tcode{e} is
285287
defined as follows:
286288
\begin{itemize}
@@ -290,12 +292,17 @@
290292
\item If \tcode{e} is a subscripting operation\iref{expr.sub} with
291293
an array operand, the set contains the potential results of that operand.
292294
\item If \tcode{e} is a class member access
293-
expression\iref{expr.ref}, the set contains the potential results of
294-
the object expression.
295+
expression\iref{expr.ref} of the form
296+
\tcode{e1 . \opt{template} e2}
297+
naming a non-static data member,
298+
the set contains the potential results of \tcode{e1}.
299+
\item if \tcode{e} is a class member access expression
300+
naming a static data member,
301+
the set contains the \grammarterm{id-expression} designating the data member.
295302
\item If \tcode{e} is a pointer-to-member
296-
expression\iref{expr.mptr.oper} whose second operand is a constant
297-
expression, the set contains the potential results of the object
298-
expression.
303+
expression\iref{expr.mptr.oper} of the form
304+
\tcode{e1 .* e2},
305+
the set contains the potential results of \tcode{e1}.
299306
\item If \tcode{e} has the form \tcode{(e1)}, the set contains the
300307
potential results of \tcode{e1}.
301308
\item If \tcode{e} is a glvalue conditional
@@ -322,48 +329,62 @@
322329
\end{note}
323330

324331
\pnum
325-
\indextext{function!named by an expression}%
326-
A function is \defn{named by an expression} as follows:
332+
A function is \defnx{named by}{function!named by expression or conversion}
333+
an expression or conversion as follows:
327334
\begin{itemize}
328335
\item
329-
A function whose name appears in an expression
330-
is named by that expression
331-
if it is the unique lookup result or the selected member
332-
of a set of overloaded functions~(\ref{basic.lookup}, \ref{over.match}, \ref{over.over}),
336+
A function is named by an expression or conversion
337+
if it is the unique result of a name lookup or the selected member
338+
of a set of overloaded functions~(\ref{basic.lookup}, \ref{over.match}, \ref{over.over})
339+
in an overload resolution performed
340+
as part of forming that expression or conversion,
333341
unless it is a pure virtual function and either
334-
its name is not explicitly qualified or
342+
the expression is not an \grammarterm{id-expression} naming the function with
343+
an explicitly qualified name or
335344
the expression forms a pointer to member\iref{expr.unary.op}.
336345
\begin{note} This covers
337346
taking the address of functions~(\ref{conv.func}, \ref{expr.unary.op}),
338347
calls to named functions\iref{expr.call},
339348
operator overloading\iref{over},
340349
user-defined conversions\iref{class.conv.fct},
341-
allocation functions for placement \grammarterm{new-expression}{s}\iref{expr.new}, as well as
350+
allocation functions for \grammarterm{new-expression}{s}\iref{expr.new}, as well as
342351
non-default initialization\iref{dcl.init}.
343352
A constructor selected to copy or move an object of class type
344-
is considered to be named by an expression
353+
is considered to be named by an expression or conversion
345354
even if the call is actually elided by the implementation\iref{class.copy.elision}. \end{note}
346355
\item
347-
An allocation or deallocation function for a class
356+
A deallocation function for a class
348357
is named by a \grammarterm{new-expression}
349-
as specified in~\ref{expr.new} and~\ref{class.free}.
358+
if it is the single matching deallocation function
359+
for the allocation function selected by overload resolution,
360+
as specified in~\ref{expr.new}.
350361
\item
351362
A deallocation function for a class
352-
is named by a delete expression
363+
is named by a \grammarterm{delete-expression}
364+
if it is the selected usual deallocation function
353365
as specified in~\ref{expr.delete} and~\ref{class.free}.
354366
\end{itemize}
355367

356368
\pnum
357369
A variable \tcode{x} whose name appears as a
358-
potentially-evaluated expression \tcode{ex} is \defnx{odr-used}{odr-use} by \tcode{ex} unless
359-
applying the lvalue-to-rvalue conversion\iref{conv.lval} to \tcode{x} yields
360-
a constant expression\iref{expr.const}
361-
that does not invoke a function
362-
other than a trivial special member function\iref{special}
363-
and, if \tcode{x} is an object, \tcode{ex} is an element of
364-
the set of potential results of an expression \tcode{e}, where either the lvalue-to-rvalue
365-
conversion\iref{conv.lval} is applied to \tcode{e}, or \tcode{e} is
366-
a discarded-value expression\iref{expr.prop}.
370+
potentially-evaluated expression \tcode{e}
371+
is \defnx{odr-used}{odr-use} by \tcode{e} unless
372+
\begin{itemize}
373+
\item
374+
\tcode{x} is a reference that is
375+
usable in constant expressions\iref{expr.const}, or
376+
\item
377+
\tcode{x} is a variable of non-reference type that is
378+
usable in constant expressions and has no mutable subobjects, and
379+
\tcode{e} is an element of the set of potential results of an expression
380+
of non-volatile-qualified non-class type
381+
to which the lvalue-to-rvalue conversion\iref{conv.lval} is applied, or
382+
\item
383+
\tcode{x} is a variable of non-reference type, and
384+
\tcode{e} is an element of the set of potential results
385+
of a discarded-value expression\iref{expr.prop}
386+
to which the lvalue-to-rvalue conversion is not applied.
387+
\end{itemize}
367388

368389
\pnum
369390
A structured binding is odr-used if it appears as a potentially-evaluated expression.
@@ -376,7 +397,8 @@
376397
\pnum
377398
A virtual member
378399
function is odr-used if it is not pure.
379-
A function is odr-used if it is named by a potentially-evaluated expression.
400+
A function is odr-used if it is named by
401+
a potentially-evaluated expression or conversion.
380402
A non-placement allocation or deallocation
381403
function for a class is odr-used by the definition of a constructor of that
382404
class. A non-placement deallocation function for a class is odr-used by the
@@ -415,7 +437,10 @@
415437
\begin{itemize}
416438
\item the intervening declarative region is a block scope, or
417439
\item the intervening declarative region is the function parameter scope of a \grammarterm{lambda-expression}
418-
that has a \grammarterm{simple-capture} naming the entity or has a \grammarterm{capture-default}.
440+
that has a \grammarterm{simple-capture}
441+
naming the entity or has a \grammarterm{capture-default}, and
442+
the block scope of the \grammarterm{lambda-expression}
443+
is also an intervening declarative region.
419444
\end{itemize}
420445
\end{itemize}
421446

@@ -425,11 +450,13 @@
425450
\begin{example}
426451
\begin{codeblock}
427452
void f(int n) {
428-
[] { n = 1; }; // error, \tcode{n} is not odr-usable due to intervening lambda-expression
453+
[] { n = 1; }; // error: \tcode{n} is not odr-usable due to intervening lambda-expression
429454
struct A {
430-
void f() { n = 2; } // error, \tcode{n} is not odr-usable due to intervening function definition scope
455+
void f() { n = 2; } // error: \tcode{n} is not odr-usable due to intervening function definition scope
431456
};
432-
void g(int = n); // error, \tcode{n} is not odr-usable due to intervening function parameter scope
457+
void g(int = n); // error: \tcode{n} is not odr-usable due to intervening function parameter scope
458+
[=](int k = n) {}; // error: \tcode{n} is not odr-usable due to being
459+
// outside the block scope of the \grammarterm{lambda-expression}
433460
[&] { [n]{ return n; }; }; // OK
434461
}
435462
\end{codeblock}
@@ -696,9 +723,13 @@
696723
all refer to the same variable, non-static data member, or enumerator,
697724
or all refer to functions and function templates;
698725
in this case the class name or enumeration name is
699-
hidden\iref{basic.scope.hiding}. \begin{note} A namespace name or a
700-
class template name must be unique in its declarative
701-
region~(\ref{namespace.alias}, \ref{temp}). \end{note}
726+
hidden\iref{basic.scope.hiding}.
727+
\begin{note}
728+
A structured binding\iref{dcl.struct.bind},
729+
namespace name\iref{basic.namespace}, or
730+
class template name\iref{temp}
731+
must be unique in its declarative region.
732+
\end{note}
702733
\end{itemize}
703734
\begin{note} These restrictions apply to the declarative region into which
704735
a name is introduced, which is not necessarily the same as the region in
@@ -2373,15 +2404,20 @@
23732404
linkage if it is the name of
23742405
\begin{itemize}
23752406
\item
2376-
a variable, function or function template that is
2407+
a variable, variable template, function, or function template that is
23772408
explicitly declared \tcode{static}; or,
23782409
\item
2379-
a non-inline variable of non-volatile const-qualified type that is
2410+
a non-inline non-template variable of non-volatile const-qualified type
2411+
that is
23802412
neither explicitly declared \tcode{extern} nor previously
23812413
declared to have external linkage; or
23822414
\item
23832415
a data member of an anonymous union.
23842416
\end{itemize}
2417+
\begin{note}
2418+
An instantiated variable template that has const-qualified type
2419+
can have external linkage, even if not declared \tcode{extern}.
2420+
\end{note}
23852421

23862422
\pnum
23872423
An unnamed namespace or a namespace declared directly or indirectly within an
@@ -2414,8 +2450,12 @@
24142450
\pnum
24152451
The name of a function declared in block scope and the name of a variable declared by a
24162452
block scope \tcode{extern} declaration have linkage. If there is a visible declaration
2417-
of an entity with linkage having the same name and type, ignoring entities declared
2418-
outside the innermost enclosing namespace scope, the block scope declaration declares
2453+
of an entity with linkage, ignoring entities declared
2454+
outside the innermost enclosing namespace scope,
2455+
such that the block scope declaration would be
2456+
a (possibly ill-formed) redeclaration
2457+
if the two declarations appeared in the same declarative region,
2458+
the block scope declaration declares
24192459
that same entity and receives the linkage of the previous declaration. If there is more
24202460
than one such matching entity, the program is ill-formed. Otherwise, if no matching
24212461
entity is found, the block scope entity receives external linkage.
@@ -2424,9 +2464,11 @@
24242464
\begin{example}
24252465
\begin{codeblock}
24262466
static void f();
2467+
extern "C" void h();
24272468
static int i = 0; // \#1
24282469
void g() {
24292470
extern void f(); // internal linkage
2471+
extern void h(); // C language linkage
24302472
int i; // \#2: \tcode{i} has no linkage
24312473
{
24322474
extern void f(); // internal linkage

source/classes.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,8 @@
13421342
of reference type,
13431343

13441344
\item any non-variant non-static data member of const-qualified type (or array
1345-
thereof) with no \grammarterm{brace-or-equal-initializer} does not have a user-provided default constructor,
1345+
thereof) with no \grammarterm{brace-or-equal-initializer}
1346+
is not const-default-constructible\iref{dcl.init}.
13461347

13471348
\item \tcode{X} is a union and all of its variant members are of const-qualified
13481349
type (or array thereof),

source/declarations.tex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6153,7 +6153,7 @@
61536153
\pnum
61546154
Otherwise, if
61556155
the \grammarterm{qualified-id} \tcode{std::tuple_size<E>}
6156-
names a complete type,
6156+
names a complete class type with a member named \tcode{value},
61576157
the expression \tcode{std::tuple_size<E>::value}
61586158
shall be a well-formed integral constant expression
61596159
and
@@ -8071,10 +8071,7 @@
80718071
An \grammarterm{alignment-specifier} may also be applied to the declaration
80728072
of a class (in an
80738073
\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab} or
8074-
\grammarterm{class-head}\iref{class}, respectively) and to the
8075-
declaration of an enumeration (in an
8076-
\grammarterm{opaque-enum-declaration} or \grammarterm{enum-head},
8077-
respectively\iref{dcl.enum}).
8074+
\grammarterm{class-head}\iref{class}, respectively).
80788075
An \grammarterm{alignment-specifier} with an ellipsis is a pack expansion\iref{temp.variadic}.
80798076

80808077
\pnum

source/exceptions.tex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@
414414
and whose destructor has not yet begun execution,
415415
except that in the case of destruction, the variant members of a
416416
union-like class are not destroyed.
417+
\begin{note}
418+
If such an object has a reference member
419+
that extends the lifetime of a temporary object,
420+
this ends the lifetime of the reference member,
421+
so the lifetime of the temporary object is effectively not extended.
422+
\end{note}
417423
The subobjects are destroyed in the reverse order of the completion of
418424
their construction. Such destruction is sequenced before entering a
419425
handler of the \grammarterm{function-try-block} of the constructor or destructor,

0 commit comments

Comments
 (0)