This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2661. Missing disambiguation rule for pure-specifier vs. brace-or-equal-initializer

Section: 11.4.1  [class.mem.general]     Status: open     Submitter: Richard Smith     Date: 2022-10-07

Subclause 11.4.1 [class.mem.general] has this grammar:

        declarator virt-specifier-seq[opt] pure-specifier[opt]
        declarator brace-or-equal-initializer[opt]

        = 0

The primary issue is that foo = 0 matches both member-declarator productions. Secondarily, a declarator by itself is also ambiguous.

Code such as virtual FunctionType f = 0; can be valid, so disambiguation on the syntactic form of the declarator is not possible.

Suggested resolution:

Change and add before 11.4.1 [class.mem.general] paragraph 1 as follows:

        declarator virt-specifier-seqopt pure-specifieropt
        declarator brace-or-equal-initializeropt
The token sequence = 0 is treated as a pure-specifier if the type of the declarator-id ( [dcl.meaning.general]) is a function type, and is otherwise treated as a brace-or-equal-initializer. [ Note: If the member declaration acquires a function type through template instantiation, the program is ill-formed; see 13.9.1 [temp.spec.general]. --end note ]