Title
Missing disambiguation rule for pure-specifier vs. brace-or-equal-initializer
Status
dr
Section
11.4.1 [class.mem.general]
Submitter
Richard Smith

Created on 2022-10-07.00:00:00 last changed 3 weeks ago

Messages

Date: 2024-02-16.23:23:05

Proposed resolution (approved by CWG 2024-02-16):

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

    member-declarator:
        declarator virt-specifier-seqopt pure-specifieropt
        declarator brace-or-equal-initializeropt
In the absence of a virt-specifier-seq, the token sequence = 0 is treated as a pure-specifier if the type of the declarator-id (9.3.4.1 [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 ]
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

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

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

    pure-specifier:
        = 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.

History
Date User Action Args
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2024-02-16 23:23:05adminsetstatus: open -> tentatively ready
2022-12-04 14:18:19adminsetmessages: + msg7085
2022-10-07 00:00:00admincreate