This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]