The warning:

   t.cc:2: warning: `class A' has virtual functions but non-virtual destructor

when compiling this code with "-Wall"

struct A
{
   virtual void test() = 0;

protected:
   ~A() {}
};

is superfluous: 

Yes, A is obviously intended as base class for polymorphic usage since it has 
virtual functions.

But in this case both a public/virtual or protected/non-virtual destructor 
suffice; in the second case 
there is no problem with polymorphic destruction, the case that would require a 
virtual destructor to 
work correctly, since it is forbidden [to any "outsiders", i.e. all code that 
is not part of a class derived 
from A, which is ok for the general case].

Please consider updating the rule for the warning to be
  "Warn if the destructor of an 'obvious' base class is neither virtual nor 
protected".

-- 
           Summary: g++ reports superfluous warning for non-
                    virtual/protected base destructor
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at cohi dot at
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: any
  GCC host triplet: any
GCC target triplet: any


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

Reply via email to