Skip to content

Commit 5b3d3b6

Browse files
committed
CWG2631 Immediate function evaluations in default arguments
1 parent bd92d7b commit 5b3d3b6

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

source/basic.tex

+14
Original file line numberDiff line numberDiff line change
@@ -5576,6 +5576,10 @@
55765576
\item
55775577
The constituent expression of an expression is that expression.
55785578
\item
5579+
The constituent expression of a conversion is
5580+
the corresponding implicit function call, if any, or
5581+
the converted expression otherwise.
5582+
\item
55795583
The constituent expressions of a \grammarterm{braced-init-list} or
55805584
of a (possibly parenthesized) \grammarterm{expression-list}
55815585
are the constituent expressions of the elements of the respective list.
@@ -5623,6 +5627,16 @@
56235627
Expressions appearing in the \grammarterm{compound-statement} of a \grammarterm{lambda-expression}
56245628
are not subexpressions of the \grammarterm{lambda-expression}.
56255629
\end{note}
5630+
% FIXME: We never define "potentially-evaluated expression".
5631+
The \defnadjx{potentially-evaluated}{subexpressions}{subexpression} of
5632+
an expression, conversion, or \grammarterm{initializer} $E$ are
5633+
\begin{itemize}
5634+
\item
5635+
the constituent expressions of $E$ and
5636+
\item
5637+
the subexpressions thereof that
5638+
are not subexpressions of a nested unevaluated operand\iref{expr.context}.
5639+
\end{itemize}
56265640

56275641
\pnum
56285642
A \defn{full-expression} is

source/classes.tex

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

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

source/declarations.tex

+14-1
Original file line numberDiff line numberDiff line change
@@ -3992,7 +3992,12 @@
39923992
copy-initialization semantics\iref{dcl.init}.
39933993
The names in the
39943994
default argument are looked up, and the semantic constraints are checked,
3995-
at the point where the default argument appears.
3995+
at the point where the default argument appears, except that
3996+
an immediate invocation\iref{expr.const} that
3997+
is a potentially-evaluated subexpression\iref{intro.execution} of
3998+
the \grammarterm{initializer-clause} in a \grammarterm{parameter-declaration} is
3999+
neither evaluated
4000+
nor checked for whether it is a constant expression at that point.
39964001
Name lookup and checking of semantic constraints for default
39974002
arguments of templated functions are performed as described in~\ref{temp.inst}.
39984003
\begin{example}
@@ -4671,6 +4676,14 @@
46714676
\end{note}
46724677
\end{itemize}
46734678

4679+
\pnum
4680+
An immediate invocation\iref{expr.const} that is not evaluated where
4681+
it appears (\ref{dcl.fct.default}, \ref{class.mem.general})
4682+
is evaluated and checked for whether it is
4683+
a constant expression at the point where
4684+
the enclosing initializer is used in
4685+
a function call, a constructor definition, or an aggregate initialization.
4686+
46744687
\pnum
46754688
An \grammarterm{initializer-clause} followed by an ellipsis is a
46764689
pack expansion\iref{temp.variadic}.

source/expressions.tex

+1-2
Original file line numberDiff line numberDiff line change
@@ -7910,8 +7910,7 @@
79107910
or
79117911

79127912
\item
7913-
a subexpression of one of the above
7914-
that is not a subexpression of a nested unevaluated operand\iref{term.unevaluated.operand}.
7913+
a potentially-evaluated subexpression of one of the above.
79157914
\end{itemize}
79167915

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

source/templates.tex

+5-4
Original file line numberDiff line numberDiff line change
@@ -5956,10 +5956,11 @@
59565956
It is unspecified whether or not an implementation implicitly instantiates a
59575957
virtual member function of a class template if the virtual member function would
59585958
not otherwise be instantiated.
5959-
The use of a template specialization in a default argument
5960-
shall not cause the template to be implicitly instantiated except that a
5961-
class template may be instantiated where its complete type is needed to determine
5962-
the correctness of the default argument.
5959+
The use of a template specialization in
5960+
a default argument or default member initializer
5961+
shall not cause the template to be implicitly instantiated except
5962+
where needed to determine
5963+
the correctness of the default argument or default member initializer.
59635964
The use of a default argument in a
59645965
function call causes specializations in the default argument to be implicitly
59655966
instantiated.

0 commit comments

Comments
 (0)