This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/5376: method name mismatch in derived classes inside a namespace
- From: at at mediaforce dot fr
- To: gcc-gnats at gcc dot gnu dot org
- Date: 14 Jan 2002 10:43:35 -0000
- Subject: c++/5376: method name mismatch in derived classes inside a namespace
- Reply-to: at at mediaforce dot fr
>Number: 5376
>Category: c++
>Synopsis: method name mismatch in derived classes inside a namespace
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Jan 14 02:46:17 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Alain TRISTAN - MEDIA FORCE
>Release: 2.96 20000731
>Organization:
>Environment:
Linux mandrake 8 - x86
>Description:
namespace nspbug
{
class A
{
public:
int method1() { return 1 ; } ;
} ;
class B : public A
{
public:
int method1(int v) { return v ; } ;
} ;
} ;
main ()
{
nspbug::B theclassB ;
// this is OK
((nspbug::A)theclassB).method1() ;
// this fails but should work
theclassB.method1() ;
}
>How-To-Repeat:
Just compile the source code given
>Fix:
A cast to the base class makes it work, but this is ugly and very tough to maintain through software development phases. (This kind of "forced" cast is dangerous).
>Release-Note:
>Audit-Trail:
>Unformatted: