[Bug c++/47011] ICE when using attribute optimize

mat at lcs dot mit.edu gcc-bugzilla@gcc.gnu.org
Tue Sep 20 13:19:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47011

--- Comment #3 from Mat Hostetter <mat at lcs dot mit.edu> 2011-09-20 12:32:47 UTC ---
I am seeing the same crash with gcc 4.4.[3456], on x86_64. It works on 4.6.1.

I encountered this crash when simply upgrading to the latest boost (1.47.0),
which uses attribute optimize, so this is likely to affect other people.

But the bug is more surprising and subtle than just the crash. It can silently
generate incorrect code, which took me longer to track down.

If you compile my attached code optimized you get the internal compiler error.
If you compile it unoptimized, g++ silently changes the calling convention for
vector::begin from by-value to by-reference -- but only if a completely
unrelated empty function is marked with attribute optimize! 

In the full example this meant g++ miscompiled std::vector::begin to use the
wrong calling convention, which when linked into other objects expecting the
proper calling convention would cause a crash.



More information about the Gcc-bugs mailing list