Title
Grammar ambiguity for nodeclspec-function-declaration
Status
open
Section
9.1 [dcl.pre]
Submitter
lprv

Created on 2025-10-15.00:00:00 last changed 2 days ago

Messages

Date: 2026-03-10.22:12:14

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]
Date: 2025-10-15.00:00:00

(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.

History
Date User Action Args
2026-03-10 22:12:14adminsetmessages: + msg8503
2025-10-15 00:00:00admincreate