This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31397] Useful compiler warning missing (virtual functions in derived classes used without 'virtual')
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Jun 2011 16:13:15 +0000
- Subject: [Bug c++/31397] Useful compiler warning missing (virtual functions in derived classes used without 'virtual')
- Auto-submitted: auto-generated
- References: <bug-31397-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31397
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-21 16:12:42 UTC ---
G++ 4.7 implements C++0x explicit override control so you can add 'override'
class B : public A
{
B( int y );
~B();
int f( int x ) override;
};
and you'll get an error if it doesn't actually override a virtual function from
a base class.
It's not *quite* what you want, but you could use it to check whether B::f
overrides a virtual (and so you want to add 'virtual' to it) without checking
the declaration of A::f