c++/9791: -Woverloaded-virtual reports hiding of destructor
georgeh@aya.yale.edu
georgeh@aya.yale.edu
Fri Feb 21 18:06:00 GMT 2003
>Number: 9791
>Category: c++
>Synopsis: -Woverloaded-virtual reports hiding of destructor
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 21 18:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: George Heintzelman
>Release: gcc-3.2.2
>Organization:
>Environment:
Solaris 8
>Description:
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.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list