This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118f. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-11-07


3062. Overlapping specification of default template arguments

Section: 9.3.4.7  [dcl.fct.default]     Status: ready     Submitter: Brian Bi     Date: 2025-08-13

(From submission #750.)

As written, 9.3.4.7 [dcl.fct.default] applies to default arguments for constant template parameters, which are specified in 13.2 [temp.param] and 13.4.3 [temp.arg.nontype]. Remove the overlap.

Proposed resolution (approved by CWG 2025-11-06):

  1. Change in 9.3.4.7 [dcl.fct.default] paragraph 1 as follows:

    If an initializer-clause is specified in a parameter-declaration that is not a template-parameter (13.2 [temp.param]), this initializer-clause is used as a default argument. [Note 1: Default arguments will be used in calls where trailing arguments are missing (7.6.1.3 [expr.call]). —end note]
  2. Change in 9.3.4.7 [dcl.fct.default] paragraph 3 as follows:

    A default argument shall be specified only in the parameter-declaration-clause of a function declaration or lambda-declarator or in a template-parameter (13.2 [temp.param]). A default argument shall not be specified for a template parameter pack or a function parameter pack. If it is specified in a parameter-declaration-clause, it A default argument shall not occur within a declarator or abstract-declarator of a parameter-declaration. [ Footnote: .... ]
  3. Change in 13.2 [temp.param] paragraph 17 as follows:

    A default template argument is a template argument (13.4 [temp.arg]) specified after = in a template-parameter . A default template argument may be specified for any kind of template parameter that is not shall not be specified for a template parameter pack (13.7.4 [temp.variadic]). A default template argument may be specified in a template declaration. ...