From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24286 invoked by alias); 20 Jan 2003 19:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 24258 invoked by uid 71); 20 Jan 2003 19:36:00 -0000 Resent-Date: 20 Jan 2003 19:36:00 -0000 Resent-Message-ID: <20030120193600.24257.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, axiong@ca.ibm.com Received: (qmail 19782 invoked by uid 48); 20 Jan 2003 19:35:07 -0000 Message-Id: <20030120193507.19781.qmail@sources.redhat.com> Date: Mon, 20 Jan 2003 19:36:00 -0000 From: axiong@ca.ibm.com Reply-To: axiong@ca.ibm.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/9377: g++ 64bit calls wrong function -> Multi-inheritance: pointer to member function of the 2nd base calss points to wrong place X-SW-Source: 2003-01/txt/msg01122.txt.bz2 List-Id: >Number: 9377 >Category: c++ >Synopsis: g++ 64bit calls wrong function -> Multi-inheritance: pointer to member function of the 2nd base calss points to wrong place >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Jan 20 19:36:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Guan-Zhu (Andrew) Xiong >Release: gcc version 3.2 >Organization: >Environment: Linux Version 2.4.19: SuSE SLES 8 (ppc) - Kernel 2.4.19-ul1-ppc64-SMP (34). >Description: => For 64-bit g++ compiling, for the following Multi-inheritance: struct B1 struct B2 struct D: B1, B2 pointer to member function of the 2nd base class B2 points to a wrong place. We want to call the function bar() through a pointer to memebr function of B2, but another function foo() defined in the drived calss is called. => For the given C++ code, if we compile it with 646-bit g++ compiler (/opt/cross/bin/powerpc64-linux-g++) and then run it, we have output: -------------------- B1::foo() is called The correct output sould be: -------------------- D::bar() is called >How-To-Repeat: /********************************************************* * -> compile the code with 64-bit g++ compiler * - like: powerpc64-linux-g++ -o hello hello.C * -> run it * - hello ********************************************************/ #include struct B1{ virtual char *foo() { return "B1::foo() is called "; } }; struct B2{ virtual char * bar() { return "B2::bar() is called "; } }; struct D : B1, B2 { //change the order of B1 and B2 -> passed char* foo() { return "D::foo() is called "; } char* bar() { return "D::bar() is called "; } }; typedef char * (D::*PMF)(); PMF select() { return 0; } //put this function here to avoid memory fault main() { D *d1ptr = new D ; PMF aPMF = (char *(D::*)()) &B2::bar ; printf( "%s\n", (d1ptr->*aPMF)() ) ; return 0 ; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: