http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51549
Bug #: 51549 Summary: QList::operator[] crash in 32bit release version on MacOS for gcc 4.2.1 Classification: Unclassified Product: gcc Version: 4.2.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: sami.lehto...@digia.com Created attachment 26076 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26076 Example application to reproduce the issue There is a bug in the way how gcc optimizes QList::operator[] so that it leads to a crash on MacOS. Detailed description: This can be reproduced only when building a release version of the application with Qt 4.7.3 (or newer, we didn't tried with older Qt versions) to MacOS Carbon or 32bit Cocoa. One of our testing computer (to reproduce the issue) is running with Xcode 3.2.6 (containing gcc 4.2.1 Apple build 5666) and MacOS 10.6.8. The problem will also be visible if you let qmake generate a Xcode project rather than a Makefile. This cannot be reproduced with debug version in Carbon/32bit Cocoa. And this cannot be reproduced at all if building to 64bit Cocoa. Also, this cannot be reproduced if using the flag -fno-tree-vrp in gcc or if building with llvm-gcc. When using Qt 4.5.3, Xcode 3.1.4 (containing gcc 4.0.1 Apple build 5493) on MacOS 10.5.8 this cannot be reproduced. We haven't been able to reproduced this on Windows/Linux computers. Other information: The QList::operator[] is compiled as "inline" for the release version. When building for the debug version the functionality is not compiled inline and there are no crashes observed. Workaround: Use QList::value() instead of QList::operator[] Note: QList::value() is neither compiled as inline for debug nor for release version. Example code to reproduce the problem: Build the attached example application with: qmake -spec macx-g++ make Start the application: ./testQListAccess.app/Contents/MacOS/testQListAccess -> crash in CPoint::x() because the reference to this object which was passed by QList::operator[] is wrong. You can deactivate in the example code in the file testQListAccess.cpp the line 138 where the QList::operator[] is used and activate the code part at line 140 which is using QList::value(). With this "workaround" the application will run.