This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12747] New: GCC generates poor code for temporary structs
- From: "jbuck at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Oct 2003 18:11:02 -0000
- Subject: [Bug c++/12747] New: GCC generates poor code for temporary structs
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12747
Summary: GCC generates poor code for temporary structs
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Keywords: pessimizes-code
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jbuck at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
This problem has been discussed for a decade, but I couldn't find a clear example
in the Bugzilla database, so here is one.
In this example we have a simple C++ bit vector class. operator[] is overloaded
in the usual way, to return a proxy object, so that C-like array notation can be
used. However, the code sucks: typically we wind up with many dead stores to
the stack. The example includes two routines: copy, which uses the operator[],
and copy_2, which directly calls getBit and setBit. The compiler should be able
to generate equally good code for copy and copy_2.