This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/5376: method name mismatch in derived classes inside a namespace



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]