C++ is broken

H.J. Lu hjl@lucon.org
Wed Jul 29 08:25:00 GMT 1998


Hi,

C++ is basically broken on certain platforms like Linux/Alpha. The
problem is very tricky. Here is what I found out:

1. egcs 1.0.3 is ok.
2. Linux/Alpha uses thunks and defines ASM_OUTPUT_MI_THUNK.
3. Linux/Alpha generates a global constructor to create vtable.
4. In finish_file () from cp/decl2.c, it does

	/* do_ctors will reverse the lists for messing up.  */
	if (needs_messing_up)
	{
	    do_ctors ();
	}

where all the virtual functions in a class is referenced
in the global constructor to create vtable for the class,
including the pure virtual one.
5. But the pure virtual functions are replaced by __pure_virtual
after do_ctors () is called. That leaves the the pure virtual
functions referenced in the global constructor undefined.

We should fix it in egcs 1.1.

Thanks.

H.J.



More information about the Gcc-bugs mailing list