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