c++/9377: g++ 64bit calls wrong function -> Multi-inheritance: pointer to member function of the 2nd base calss points to wrong place

Wolfgang Bangerth bangerth@ticam.utexas.edu
Tue Jan 21 21:36:00 GMT 2003


The following reply was made to PR c++/9377; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Andrew Xiong <axiong@ca.ibm.com>
Cc: bangerth@dealii.org, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9377: g++ 64bit calls wrong function -> Multi-inheritance:
 pointer to member function of the 2nd base calss points to wrong place
Date: Tue, 21 Jan 2003 15:30:10 -0600 (CST)

 Andrew,
 Thanks for the answers.
 
 >         d1ptr = (D*) new B2 ;  //with the cast, we can also do this
 >         printf( "%s\n", (d1ptr->*select(1))() ) ;
 
 This can really only work by chance. By creating a B2 you run code that 
 sets up the virtual function table for a B2, and invoking a function from 
 the D function table will invoke undefined behavior. I also bet that this 
 will not work with virtual inheritance.
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 
 



More information about the Gcc-prs mailing list