Skip to content

Commit 47a1382

Browse files
burblebeetkoeppe
authored andcommitted
CWG2631 Immediate function evaluations in default arguments
In [intro.execution], cross-reference term for "unevaluated operand": We have started attaching labels to defined terms, so we can directly refer to the terms instead of just the containing subclause. Fixes NB FR 005 (C++23 CD).
1 parent b57af5a commit 47a1382

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

source/basic.tex

+13
Original file line numberDiff line numberDiff line change
@@ -5585,6 +5585,10 @@
55855585
\item
55865586
The constituent expression of an expression is that expression.
55875587
\item
5588+
The constituent expression of a conversion is
5589+
the corresponding implicit function call, if any, or
5590+
the converted expression otherwise.
5591+
\item
55885592
The constituent expressions of a \grammarterm{braced-init-list} or
55895593
of a (possibly parenthesized) \grammarterm{expression-list}
55905594
are the constituent expressions of the elements of the respective list.
@@ -5632,6 +5636,15 @@
56325636
Expressions appearing in the \grammarterm{compound-statement} of a \grammarterm{lambda-expression}
56335637
are not subexpressions of the \grammarterm{lambda-expression}.
56345638
\end{note}
5639+
The \defnadjx{potentially-evaluated}{subexpressions}{subexpression} of
5640+
an expression, conversion, or \grammarterm{initializer} $E$ are
5641+
\begin{itemize}
5642+
\item
5643+
the constituent expressions of $E$ and
5644+
\item
5645+
the subexpressions thereof that
5646+
are not subexpressions of a nested unevaluated operand\iref{term.unevaluated.operand}.
5647+
\end{itemize}
56355648

56365649
\pnum
56375650
A \defn{full-expression} is

source/classes.tex

+5
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@
659659
shall not directly or indirectly cause the implicit definition of a
660660
defaulted default constructor for the enclosing class or the
661661
exception specification of that constructor.
662+
An immediate invocation\iref{expr.const} that
663+
is a potentially-evaluated subexpression\iref{intro.execution}
664+
of a default member initializer
665+
is neither evaluated nor checked for whether it
666+
is a constant expression at the point where the subexpression appears.
662667

663668
\pnum
664669
A member shall not be declared with the \keyword{extern}

source/declarations.tex

+14-1
Original file line numberDiff line numberDiff line change
@@ -4004,7 +4004,12 @@
40044004
copy-initialization semantics\iref{dcl.init}.
40054005
The names in the
40064006
default argument are looked up, and the semantic constraints are checked,
4007-
at the point where the default argument appears.
4007+
at the point where the default argument appears, except that
4008+
an immediate invocation\iref{expr.const} that
4009+
is a potentially-evaluated subexpression\iref{intro.execution} of
4010+
the \grammarterm{initializer-clause} in a \grammarterm{parameter-declaration} is
4011+
neither evaluated
4012+
nor checked for whether it is a constant expression at that point.
40084013
Name lookup and checking of semantic constraints for default
40094014
arguments of templated functions are performed as described in~\ref{temp.inst}.
40104015
\begin{example}
@@ -4684,6 +4689,14 @@
46844689
\end{note}
46854690
\end{itemize}
46864691

4692+
\pnum
4693+
An immediate invocation\iref{expr.const} that is not evaluated where
4694+
it appears\iref{dcl.fct.default,class.mem.general}
4695+
is evaluated and checked for whether it is
4696+
a constant expression at the point where
4697+
the enclosing \grammarterm{initializer} is used in
4698+
a function call, a constructor definition, or an aggregate initialization.
4699+
46874700
\pnum
46884701
An \grammarterm{initializer-clause} followed by an ellipsis is a
46894702
pack expansion\iref{temp.variadic}.

source/expressions.tex

+1-2
Original file line numberDiff line numberDiff line change
@@ -7923,8 +7923,7 @@
79237923
or
79247924

79257925
\item
7926-
a subexpression of one of the above
7927-
that is not a subexpression of a nested unevaluated operand\iref{term.unevaluated.operand}.
7926+
a potentially-evaluated subexpression\iref{intro.execution} of one of the above.
79287927
\end{itemize}
79297928

79307929
\indextext{function!needed for constant evaluation}%

source/templates.tex

+8-4
Original file line numberDiff line numberDiff line change
@@ -5978,13 +5978,17 @@
59785978
It is unspecified whether or not an implementation implicitly instantiates a
59795979
virtual member function of a class template if the virtual member function would
59805980
not otherwise be instantiated.
5981-
The use of a template specialization in a default argument
5982-
shall not cause the template to be implicitly instantiated except that a
5983-
class template may be instantiated where its complete type is needed to determine
5984-
the correctness of the default argument.
5981+
The use of a template specialization in
5982+
a default argument or default member initializer
5983+
shall not cause the template to be implicitly instantiated except
5984+
where needed to determine
5985+
the correctness of the default argument or default member initializer.
59855986
The use of a default argument in a
59865987
function call causes specializations in the default argument to be implicitly
59875988
instantiated.
5989+
Similarly, the use of a default member initializer
5990+
in a constructor definition or an aggregate initialization
5991+
causes specializations in the default member initializer to be instantiated.
59885992

59895993
\pnum
59905994
If a function template

0 commit comments

Comments
 (0)