[MAJOR BUG] g++ 2.95.x generates invalid code for KDE 3.3.0

Thiago Macieira thiago.macieira at kdemail.net
Sun Sep 19 16:51:50 BST 2004

Guillaume Laurent wrote:
>On Sunday 19 September 2004 15:24, Thiago Macieira wrote:
>> - a constructor for one of the classes inheriting the virtual base calls
>> one function which in turn calls an overridden virtual function
>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.

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.

Leo Savernik wrote:
>Why discouraged? This is the very first gross bug that I've ever
>encountered with 2.95 

Exactly. So there's a major bug. Therefore, it's people using it that should 
properly fix their compilers, not us working around the bugs.

g++ 2.95.4 on Linux is known now to produce invalid code. It should no 
longer be used. As a compromise till people upgrade their compilers (to a 
2.95.5, for instance, if that ever comes along), we should provide code 
that doesn't trigger the bug for a while, but not for long.

As for its use on other platforms, I said "not supported" meaning that the 
user's problem of making it work, not ours.

  Thiago Macieira  -  Registered Linux user #65028
   thiago (AT) macieira (DOT) info
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040919/57aa838e/attachment.sig>

More information about the kde-core-devel mailing list