This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/20408] Unnecessary code generated for empty structs
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Sep 2005 16:25:56 -0000
- Subject: [Bug middle-end/20408] Unnecessary code generated for empty structs
- References: <20050310154814.20408.chris@bubblescope.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-09-04 16:25 -------
For
struct Foo {};
void foo(const Foo&);
void bar(Foo);
void fooc(void)
{
foo(Foo());
}
void barc(void)
{
bar(Foo());
}
we get different initializers for the Foo& and the Foo case:
void fooc() ()
{
struct Foo D.1594;
<bb 0>:
D.1594 = {};
foo (&D.1594);
return;
}
void barc() ()
{
struct Foo D.1613;
<bb 0>:
D.1613 = 0;
bar (D.1613) [tail call];
return;
}
The former looks correct and does not produce initialization code
for the temporary. The latter produces an unneccessary (uninitialized)
initialization of the pass-by-value stack slot on x86.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20408