Title
Address of pure virtual function vs odr-use
Status
cd4
Section
6.3 [basic.def.odr]
Submitter
Richard Smith

Created on 2013-01-31.00:00:00 last changed 87 months ago

Messages

Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

Date: 2013-04-15.00:00:00

Proposed resolution (April, 2013):

Change 6.3 [basic.def.odr] paragraph 3 as follows:

...A virtual member function is odr-used if it is not pure. A function whose name appears as a potentially-evaluated expression is odr-used if it is the unique lookup result or the selected member of a set of overloaded functions (6.5 [basic.lookup], 12.2 [over.match], 12.3 [over.over]), unless it is a pure virtual function and either its name is not explicitly qualified or the expression forms a pointer to member (5.3.1). [Note:...
Date: 2022-09-25.18:08:42

According to 6.3 [basic.def.odr] paragraph 3,

A function whose name appears as a potentially-evaluated expression is odr-used if it is the unique lookup result or the selected member of a set of overloaded functions (6.5 [basic.lookup], 12.2 [over.match], 12.3 [over.over]), unless it is a pure virtual function and its name is not explicitly qualified.

In the following example, consequently, S::f is odr-used but not defined, and (because it is an undefined odr-used inline function) a diagnostic is required:

  namespace {
    struct S {
      inline virtual void f() = 0;
    };
   void (S::*p) = &S::f;
  }

However, S::f cannot be called through such a pointer-to-member, so forming a pointer-to-member should not cause a pure virtual function to be odr-used. There is implementation divergence on this point.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: + msg5327
2014-11-24 00:00:00adminsetstatus: ready -> dr
2014-03-03 00:00:00adminsetstatus: review -> ready
2013-05-03 00:00:00adminsetmessages: + msg4316
2013-05-03 00:00:00adminsetstatus: open -> review
2013-01-31 00:00:00admincreate