pointer to class causes core dump

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Thu Apr 13 13:22:00 GMT 2000


> This seemed completely legit, but the gcc code dumped core, while the VC++ 
> worked fine.
> 
> To fix the problem, we got rid of the BaseClassPtr and replaced it with
> an instance of CDerivedClass.  Any insight on why the executable would
> complain is greatly appreciated.

Without seeing more of the code, it is hard to guess what the problem
was. The line you quote indeed looks valid (although CDerivedClass
only sounds like it is derived from CBaseClass - I have no means to
check). I very much doubt that the code crashes on the assignment - it
may crash later. For example, you may have casted CBaseClass* to void*
and then to CDerivedClass* - that may work in VC++, but may crash in
g++ (for example, if multiple or virtual inheritance is involved). If
that would happen, it would be a bug in your program, not in g++ (and
neither in VC++).

Regards,
Martin



More information about the Gcc mailing list