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

2024-12-19


2653. Can an explicit object parameter have a default argument?

Section: 9.3.4.6  [dcl.fct]     Status: C++23     Submitter: GB     Date: 2022-11-03     Liaison: EWG

P2720R0 comment GB 051

[Accepted at the November, 2022 meeting.]

The syntax and semantics appear to allow:

  struct S { void f(this const S& = S{}); };
This is probably no more than an oddity, but perhaps it should be prevented.

Proposed resolution (approved by CWG 2022-11-08):

Change in 9.3.4.6 [dcl.fct] paragraph 3 as follows:

parameter-declaration:
    attribute-specifier-seqopt thisopt decl-specifier-seq declarator
    attribute-specifier-seqopt thisopt decl-specifier-seq declarator = initializer-clause
    attribute-specifier-seqopt thisopt decl-specifier-seq abstract-declaratoropt
    attribute-specifier-seqopt thisopt decl-specifier-seq abstract-declaratoropt = initializer-clause