Test case: struct Foo { inline virtual void func() = 0; }; struct Bar : public Foo { void func() { } }; int main() { Foo *f = new Bar; f->func(); } Using trunk: g++ (GCC) 4.9.0 20140219 (experimental) g++ -c -Wall -Wextra t.cc t.cc:2:23: warning: inline function 'virtual void Foo::func()' used but never defined inline virtual void func() = 0; ^ But Foo::func is never actually used. Analysis by Nick Lewycky: The relevant [basic.odr]/2 text is: "A virtual member function is odr-used if it is not pure. A non-overloaded function whose name appears as a potentially-evaluated expression or a member of a set of candidate functions, if selected by overload resolution when referred to from a potentially-evaluated expression, is odr-used, unless it is a pure virtual function and its name is not explicitly qualified." Since the function isn't ODR-used, there's no need for it to have a definition: "An inline function shall be defined in every translation unit in which it is odr-used." [basic.odr]/3
Furthermore, if the testcase ended with: f->Foo::func(); then the warning should be issued.
Author: jason Date: Fri Feb 21 14:56:46 2014 New Revision: 208001 URL: http://gcc.gnu.org/viewcvs?rev=208001&root=gcc&view=rev Log: PR c++/60277 * call.c (build_array_conv): Don't crash on VLA. Added: trunk/gcc/testsuite/g++.dg/cpp1y/vla13.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c
I also wanted to report this bug (it reproduces on trunk), but found this report and an old duplicate: PR11067 which is resolved as WONTFIX. IMHO it's not too difficult to fix, including the case "f->Foo::func();" (though I did not regtest the fix, so I can't say for sure). The question is: should this warning be emitted or not? Clang does not produce such warning.
Fixed in GCC 9.3.0+ and in GCC 10 by r10-5027-g99150b053e1 and r9-8069-ge3edafbca9f3553 (PR 92695). The patch includes exactly a testcase which is similar enough to this one. So closing as fixed.