[MAJOR BUG] g++ 2.95.x generates invalid code for KDE 3.3.0
Guillaume Laurent
glaurent at telegraph-road.org
Sun Sep 19 23:34:00 BST 2004
On Sunday 19 September 2004 17:51, Thiago Macieira wrote:
> Guillaume Laurent wrote:
> >
> >Virtual functions do not work in ctors in general.
>
> They work fine in g++ 3.3/3.4 and there's nothing in the standard that
> prevents us from doing that.
>
> The problem you're alluding to is that people expect constructors to call
> the overriden functions in more-derived classes. That isn't supported by
> the standard: both g++ 2.95 and the 3.x series work correctly. Calls to
> virtual functions inside a constructor are not virtual at all.
That's what I meant.
> The problem in this case is that a virtual function is called *indirectly*
> from inside the constructor: the constructor calls a function which in turn
> calls the virtual function.
It's the exact same problem, as long as you're in a ctor, the vtable isn't
built yet so virtuals behave like non-virtual functions.
--
Guillaume.
http://www.telegraph-road.org
More information about the kde-core-devel
mailing list