public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5376: method name mismatch in derived classes inside a namespace
@ 2002-01-14  2:46 at
  0 siblings, 0 replies; 2+ messages in thread
From: at @ 2002-01-14  2:46 UTC (permalink / raw)
  To: gcc-gnats


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/5376: method name mismatch in derived classes inside a namespace
@ 2002-01-14  5:58 rodrigc
  0 siblings, 0 replies; 2+ messages in thread
From: rodrigc @ 2002-01-14  5:58 UTC (permalink / raw)
  To: at, gcc-bugs, gcc-prs, nobody

Synopsis: method name mismatch in derived classes inside a namespace

State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Mon Jan 14 05:58:43 2002
State-Changed-Why:
    Your code is wrong.
    See "The C++ Programming Language, 3rd ed." by Stroustrup, section 15.2.2 Inheritance and Using-Declarations:
    "Overload resolution is not applied across different scopes.
    In particular, ambiguities between functions from different base classes are not resolved based on
    argument type."
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5376


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-14 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-14  2:46 c++/5376: method name mismatch in derived classes inside a namespace at
2002-01-14  5:58 rodrigc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).