This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/20408] New: Unnessasary code generated for empty structs
- From: "chris at bubblescope dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Mar 2005 15:48:17 -0000
- Subject: [Bug middle-end/20408] New: Unnessasary code generated for empty structs
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Given an empty struct (ie struct X { };), even at high optimisation levels g++
will insist on always allocating and zeroing some memory for empty structs.
This actually effects C++ code, including libstdc++-v3, as empty structs are
often used as a means of passing around functions.
EXAMPLE
------------------
struct X {};
void foo(X);
void call_foo()
{ foo(X()); }
------------------
generates (from -O3, t70.final_cleanup is:)
-------------------------------------------------
;; Function void call_foo() (_Z8call_foov)
void call_foo() ()
{
struct X D.1597;
<bb 0>:
D.1597 = 0;
foo (D.1597) [tail call];
return;
}
---------------------------------------------
--
Summary: Unnessasary code generated for empty structs
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: chris at bubblescope dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20408