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

2026-04-17


3163. Grammar ambiguity for nodeclspec-function-declaration

Section: 9.1  [dcl.pre]     Status: open     Submitter: lprv     Date: 2025-10-15

(From submission #741.)

Consider:

  class A;
  A(A);   // #1

#1 can be interpreted as either a nodeclspec-function-declaration or a variable declaration with extra parentheses. A disambiguation rule is missing.

Possible resolution:

Change in 9.1 [dcl.pre] paragraph 11:

An ambiguity can arise in a declaration when a type-name is enclosed in parentheses. In this case, the choice is between a nodeclspec-function-declaration with an unnamed parameter and a variable declaration with extra parentheses around the declarator-id. The resolution is to consider the declaration a nodeclspec-function-declaration if its declarator-id is a qualified-id and a variable declaration otherwise. A nodeclspec-function-declaration shall declare a constructor, destructor, or conversion function. [Note 6: Because a member function cannot be subject to a non-defining declaration outside of a class definition (11.4.2 [class.mfct]), a nodeclspec-function-declaration can only be used in a template-declaration (13.1 [temp.pre]), explicit-instantiation (13.9.3 [temp.explicit]), or explicit-specialization (13.9.4 [temp.expl.spec]). —end note]