This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/31397] Useful compiler warning missing (virtual functions in derived classes used without 'virtual')


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]