Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc 4.7.2 virtual function bug

Tags:

c++

gcc

g++

mingw

There is a known bug in gcc 4.7.2 for MinGW that causes an invalid this pointer to be passed to a virtual function under some circumstances that involve virtual and non-virtual inheritance in the same class. The details are on this Bugzilla page.

This bug has bitten me, and I need to fix it for a Qt application I am writing. There is a patch in the Bugzilla page, but how do I get a working version that incorporates this patch? As far as I can tell, the GNU download page only provides the original, buggy version. And the next version of gcc after 4.7.2 is 4.8.0, which I can't use because it will be incompatible with my Qt libraries.

Do I have to build gcc from the sources, after applying the patch? I certainly want to avoid that if I can!

like image 479
TonyK Avatar asked Nov 13 '22 08:11

TonyK


1 Answers

I took Haroogan's advice (to rebuild Qt from source), but with GCC 4.8.0 instead of GCC 4.7.1. It worked! At least, I've been using it for three days now, and it hasn't thrown up any surprises yet. The only glitch was the intrinsic header files in GCC 4.8.0, which needed this patch applied to them. Other than that, it was plain sailing (i.e. it only took me two evenings).

Updated to add: I am now noticing some problems with the debugger. So perhaps I spoke too soon!

like image 182
TonyK Avatar answered Nov 15 '22 04:11

TonyK