9791 – [3.2 regression] -Woverloaded-virtual reports hiding of destructor (original) (raw)

class Base { public: virtual ~Base() { } };

class Derived: public Base { public: int Base() { return 5; } };

int main() { }

When compiled with -Woverloaded-virtual, this file produces: ../gcc-3.2.2/bin/g++ test-hiding.C -save-temps -Wall -Woverloaded-virtual test-hiding.C:3: warning: virtual Base::~Base()' was hidden test-hiding.C:9: warning: by int Derived::Base()'

which is certainly not accurate. It is true that int Derived::Base() is hiding the name of the base class inside the class, but this is not the kind of name-hiding that (I think) the warning was intended to guard against; nor is it name-hiding that is likely to lead to an error. I think -Woverloaded-virtual should not give a warning in this case.

Release: gcc-3.2.2

Environment: Solaris 8

Comment 2 Wolfgang Bangerth 2003-02-21 19:00:14 UTC

State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. The warning message is also not particularly useful, although it is probably arguable whether such a programming style is useful in itself :-)

It used to work in 2.95, but was broken in 3.0 already.
Still broken in 3.2.2, 3.3, 3.4.

W.

Comment 7 Mark Mitchell 2003-03-06 20:14:33 UTC

State-Changed-From-To: analyzed->open State-Changed-Why: Fixed in GCC 3.3.

Comment 8 Wolfgang Bangerth 2003-03-07 01:59:47 UTC

State-Changed-From-To: open->analyzed State-Changed-Why: Remains analyzed, despite fixed for 3.3 and mainline.

Comment 9 Joe Buck 2003-04-25 21:25:38 UTC

State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for 3.3.