Your message dated Tue, 3 Jun 2003 14:32:45 +0200
with message-id <[EMAIL PROTECTED]>
and subject line Bug#195806: g++: inheritance of overloaded function
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 2 Jun 2003 13:33:22 +0000
>From [EMAIL PROTECTED] Mon Jun 02 08:33:20 2003
Return-path: <[EMAIL PROTECTED]>
Received: from mpimail.mpi-hd.mpg.de [149.217.0.100] 
        by master.debian.org with esmtp (Exim 3.35 1 (Debian))
        id 19MpRA-0001Ty-00; Mon, 02 Jun 2003 08:33:20 -0500
Received: from xpc19.mpi-hd.mpg.de (xpc19.mpi-hd.mpg.de [149.217.2.99])
        by mpimail.mpi-hd.mpg.de (8.12.9/8.12.9) with ESMTP id h52DXIfO021863;
        Mon, 2 Jun 2003 15:33:18 +0200
Received: from scheit by xpc19.mpi-hd.mpg.de with local (Exim 3.35 #1 (Debian))
        id 19MpR7-00071O-00; Mon, 02 Jun 2003 15:33:17 +0200
From: Heiko Scheit <[EMAIL PROTECTED]>
To: Debian Bug Tracking System <[EMAIL PROTECTED]>
Subject: g++: inheritance of overloaded function
X-Mailer: reportbug 1.50
Date: Mon, 02 Jun 2003 15:33:17 +0200
Message-Id: <[EMAIL PROTECTED]>
Sender: Heiko Scheit <[EMAIL PROTECTED]>
Delivered-To: [EMAIL PROTECTED]
X-Spam-Status: No, hits=-6.0 required=4.0
        tests=BAYES_01,HAS_PACKAGE
        version=2.53-bugs.debian.org_2003_05_24
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_05_24 
(1.174.2.15-2003-03-30-exp)

Package: g++
Version: 2:2.95.4-14
Severity: normal

If you try to compile the program given below you will get the
following:

$ g++ test.cc
test.cc: In function `int main()':
test.cc:24: no matching function for call to `B::p1 (int)'
test.cc:16: candidates are: void B::p1()

So, the function B::p1(int) is not found even though it should be
inherited from class A.  The problem seems to be that p1 is overloaded
and p1() is redefined and p1(int) is not.  For p2 no (overloaded)
function is redefined and it works w/o problem (just comment the line
'b->p1(1);' in main): both functions are inherited from class A.

Everything also works w/o problem if b is declared as A*, instead of
B*, i.e. a pointer to the base class.

I am not sure this is a bug, but I thought that the inheritance should
work also in this case (i.e. with overloaded functions).

When using g++-3.0 I get the same result.

Many Greetings, Heiko



test.cc looks like this:
-------------------------
$ cat test.cc

#include <iostream>

using namespace std;

class A {
public:
  virtual void p1()      {cout<<"ap1 "<<endl;}
  virtual void p1(int i) {cout<<"ap1 "<<i<<endl;}
  virtual void p2()      {cout<<"ap2 "<<endl;}
  virtual void p2(int i) {cout<<"ap2 "<<i<<endl;}
};

class B : public A {
public:
  void p1() {cout<<"bp1"<<endl;}
};

int main () {
  B* b = new B;  // does not work
  //A* b = new B;  // works
  b->p1();
  b->p2();
  b->p1(1);      // comment this line and it also works
  b->p2(1);
}


-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux xpc19 2.4.19 #7 Mon Aug 19 16:01:05 CEST 2002 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages g++ depends on:
ii  cpp                    2:2.95.4-14       The GNU C preprocessor.
ii  g++-2.95               1:2.95.4-11woody1 The GNU C++ compiler.
ii  gcc-2.95               1:2.95.4-11woody1 The GNU C compiler.


---------------------------------------
Received: (at 195806-done) by bugs.debian.org; 3 Jun 2003 12:34:56 +0000
>From [EMAIL PROTECTED] Tue Jun 03 07:34:55 2003
Return-path: <[EMAIL PROTECTED]>
Received: from mail.cs.tu-berlin.de [130.149.17.13] 
        by master.debian.org with esmtp (Exim 3.35 1 (Debian))
        id 19NB0A-0001sC-00; Tue, 03 Jun 2003 07:34:55 -0500
Received: from bolero.cs.tu-berlin.de ([EMAIL PROTECTED] [130.149.19.1])
        by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id OAA03350;
        Tue, 3 Jun 2003 14:32:45 +0200 (MET DST)
Received: (from [EMAIL PROTECTED])
        by bolero.cs.tu-berlin.de (8.11.6+Sun/8.9.3) id h53CWjO21104;
        Tue, 3 Jun 2003 14:32:45 +0200 (MEST)
From: Matthias Klose <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <[EMAIL PROTECTED]>
Date: Tue, 3 Jun 2003 14:32:45 +0200
To: [EMAIL PROTECTED]
Cc: Heiko Scheit <[EMAIL PROTECTED]>
Subject: Re: Bug#195806: g++: inheritance of overloaded function
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
        <[EMAIL PROTECTED]>
X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid
Delivered-To: [EMAIL PROTECTED]
X-Spam-Status: No, hits=-21.2 required=4.0
        tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,
              REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_VM
        autolearn=ham version=2.53-bugs.debian.org_2003_05_24
X-Spam-Level: 
X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_05_24 
(1.174.2.15-2003-03-30-exp)

Closing the report.

Martin v. =?iso-8859-15?q?L=F6wis?= writes:
> Heiko Scheit <[EMAIL PROTECTED]> writes:
> 
> > I am not sure this is a bug, but I thought that the inheritance should
> > work also in this case (i.e. with overloaded functions).
> 
> This is not a bug. In standard C++, methods in a derived class hide
> methods in the base class. Any C++ book will tell you so.


Reply via email to