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] New: Useful compiler warning missing (virtual functions in derived classes used without 'virtual')


When trying to build the OOo code warning-free we turned all useful warnings on
and get rid of them.
But there is one warning that would be really useful missing. It is not
required for code correctness or safety at all, but it would be most useful to
have better understandable code.

What I/we at OOo would like to have is a warning when a when a function in a
derived class is overloaded without specifing 'virtual'. 

This would allow to identify all the cases where this is missing and in the end
it would be clear just be looking at the specific declaration of a class which
functions are virtual and which not. Right now in our sometimes very old code
it is quite troublesome to always go up in the class hierarchy in order to
check this.

Example:
class A
{
  A();
  virtual ~A();
  virtual int f( int x );
};

class B : public A
{
  B( int y );
  ~B();
  int f( int x );
};

It would be nice if there would be warnings for ~B and f not using the
'virtual' keyword. Together with the switch to treat warnings as errors this
would help to produce better understandable code.


-- 
           Summary: Useful compiler warning missing (virtual functions in
                    derived classes used without 'virtual')
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Thomas dot Lange at sun dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31397


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