This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22167] Strange optimization bug when using -Os
- From: "dahowell at directv dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jun 2005 23:48:23 -0000
- Subject: [Bug c++/22167] Strange optimization bug when using -Os
- References: <20050623233721.22167.dahowell@directv.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From dahowell at directv dot com 2005-06-23 23:48 -------
Created an attachment (id=9138)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9138&action=view)
Short test file which demonstrates optimization failuer
This is pretty much what was left of basic_string.h after I removed all the
code which was not needed to cause the bug to happen. For the curious, S was
derived from the basic_string template, A was derived from the allocator
object, and p used to be the _M_rep pointer to the basic_string::_Rep
structure. S::init was once basic_string::append.
The function do_nothing was once the allocator's dispose method, but as you can
see it now truly should do nothing. But it doesn't quite do nothing, it causes
the optimizer to fail when optimizing for size. The seemingly pointless
static_cast<A> also is needed to cause the bug. Inlining either S::init or
do_nothing will also make the bug magically disappear.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167