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

2024-11-11


1983. Inappropriate use of virt-specifier

Section: 11.4  [class.mem]     Status: CD5     Submitter: Richard Smith     Date: 2014-08-11

[Accepted as a DR at the March, 2018 (Jacksonville) meeting.]

The restriction in 11.4 [class.mem] paragraph 8 that a virt-specifier may appear only in the declaration of a virtual function is insufficient to rule out examples like the following:

  struct A { virtual void f(); };
  struct B { friend void A::f() final; };

  template<typename T> struct C { virtual void f() {} };
  template void C<int>::f() final;
  template<> void C<char>::f() final;

One possibility might be to require that a virt-specifier appear only on the first declaration of a function.

Proposed resolution (November, 2017)

Change 11.4 [class.mem] paragraph 13 as follows:

A virt-specifier-seq shall contain at most one of each virt-specifier. A virt-specifier-seq shall appear only in the first declaration of a virtual member function (11.7.3 [class.virtual]).