Bug 9791 - [3.2 regression] -Woverloaded-virtual reports hiding of destructor
Summary: [3.2 regression] -Woverloaded-virtual reports hiding of destructor
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-21 18:06 UTC by georgeh
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description georgeh 2003-02-21 18:06:00 UTC
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 3 Mark Mitchell 2003-03-06 20:06:30 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9791
Date: 6 Mar 2003 20:06:30 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 20:06:30
 
 Modified files:
 	gcc/cp         : ChangeLog class.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/warn: Woverloaded-1.C 
 
 Log message:
 	PR c++/9791
 	* class.c (get_basefndecls): Use lookup_fnfields_1.
 	
 	PR c++/9791
 	* g++.dg/warn/Woverloaded-1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3238&r2=1.3239
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.525&r2=1.526
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2472&r2=1.2473
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Woverloaded-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 4 Mark Mitchell 2003-03-06 20:06:30 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9791
Date: 6 Mar 2003 20:06:30 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 20:06:30
 
 Modified files:
 	gcc/cp         : ChangeLog class.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/warn: Woverloaded-1.C 
 
 Log message:
 	PR c++/9791
 	* class.c (get_basefndecls): Use lookup_fnfields_1.
 	
 	PR c++/9791
 	* g++.dg/warn/Woverloaded-1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3238&r2=1.3239
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.525&r2=1.526
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2472&r2=1.2473
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Woverloaded-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 5 Mark Mitchell 2003-03-06 20:08:30 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9791
Date: 6 Mar 2003 20:08:30 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 20:08:30
 
 Modified files:
 	gcc/cp         : ChangeLog class.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/warn: Woverloaded-1.C 
 
 Log message:
 	PR c++/9791
 	* class.c (get_basefndecls): Use lookup_fnfields_1.
 	
 	PR c++/9791
 	* g++.dg/warn/Woverloaded-1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.57&r2=1.3076.2.58
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.499.2.7&r2=1.499.2.8
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.72&r2=1.2261.2.73
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Woverloaded-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 

Comment 6 Mark Mitchell 2003-03-06 20:08:30 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/9791
Date: 6 Mar 2003 20:08:30 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	mmitchel@gcc.gnu.org	2003-03-06 20:08:30
 
 Modified files:
 	gcc/cp         : ChangeLog class.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/warn: Woverloaded-1.C 
 
 Log message:
 	PR c++/9791
 	* class.c (get_basefndecls): Use lookup_fnfields_1.
 	
 	PR c++/9791
 	* g++.dg/warn/Woverloaded-1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.57&r2=1.3076.2.58
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.499.2.7&r2=1.499.2.8
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.72&r2=1.2261.2.73
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Woverloaded-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
 
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.