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]

G++ dynamic_cast bug with simple example ...


Gcc 2.95.1 on Solaris 2.7 dynamic_cast bug:
using binutils2.9.1 ld and as
no special args to Gcc configure

We've found a problem with dynamic_cast in some instances.
The enclosed Test.cpp produces the error.
The enclosed Test.ii is the the preprocessed output
The enclosed Test.s shows that the first vtable entry for class
derived2, contains a non-zero "this" adjustment, when in fact it
should be 0. (Test.s line 527)
This results in a bad pointer being returned from
the internal dynamic_cast function.

It appears to be related to multiple inheritance
where the first base class has no vtable, but the second does.
Changing the order of inheritance of base1 & base2 makes it
go away, as does adding a dummy virtual function to base1.
Adding data members to the various classes to avoid 0 size
structs didn't seem to make a difference either.

Mark Boenke
Xippix Inc.
mark@aiyiyi.com
(707) 578-4065

gccbug.tgz


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