Mark Mitchel's commit to fix PR c++/16405 introduced a miscompilation in Qt. It took me a few weeks to deduce a testcase. testcase is: === Cut === extern "C" void abort( void ); struct A { A() { d = d2 = 0; width = -1; } A( int _w ) : d( 0 ), d2( 0 ), width( _w ) {} A b( const A &r ) const; int d; int d2; int width; }; A A::b( const A &r ) const { A tmp; tmp.width = width < r.width ? width : r.width; return tmp; } int main() { A a( 100 ); a = a.b( A( 10 ) ); if ( a.width != 10 ) abort(); } === Cut === The issue is that the result of "a.b(A (10))" is never copied to a, hence the if() afterwards fails.
-- Summary: forgets to deep-copy temporary return value Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: critical Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mueller at kde dot org CC: gcc-bugs at gcc dot gnu dot org,mark at codesourcery dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19317