This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34459] [4.1/4.3 Regression] incorrect code when compiled with optimization (-O1)
- 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: 14 Dec 2007 13:32:38 -0000
- Subject: [Bug c++/34459] [4.1/4.3 Regression] incorrect code when compiled with optimization (-O1)
- References: <bug-34459-15519@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from rguenth at gcc dot gnu dot org 2007-12-14 13:32 -------
Confirmed. Reduced testcase:
extern "C" void abort(void);
extern "C" void *memset(void *s, int c, __SIZE_TYPE__ n);
struct ip_addr {
void __attribute__((noinline)) verify() const
{
for (int i = 0; i < sizeof(addr_); ++i)
if (addr_[i] != 0)
abort ();
}
ip_addr() {
memset(&addr_, 0, sizeof(addr_));
}
char addr_[25];
};
struct foo {
foo(ip_addr const & a) : remote_(a) { remote_ = remote_; }
ip_addr remote_;
};
int main()
{
ip_addr a;
a.verify();
foo f(a);
f.remote_.verify();
}
On trunk after inlining we end up with main() like the following:
<bb 2>:
# a_6 = VDEF <a_4(D)>
# f_7 = VDEF <f_5(D)>
memset (&a.addr_, 0, 25);
# a_8 = VDEF <a_6>
# f_9 = VDEF <f_7>
verify (&a);
# VUSE <a_8>
# f_10 = VDEF <f_9>
f.remote_ = a;
# f_11 = VDEF <f_10>
f.remote_ = f.remote_;
# a_12 = VDEF <a_8>
# f_13 = VDEF <f_11>
verify (&f.remote_);
return 0;
and DSE chooses to remove the first store to f.remote. Whoops.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Known to fail| |4.1.3 4.3.0
Known to work| |4.2.2
Last reconfirmed|0000-00-00 00:00:00 |2007-12-14 13:32:37
date| |
Summary|incorrect code when compiled|[4.1/4.3 Regression]
|with optimization (-O1) |incorrect code when compiled
| |with optimization (-O1)
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34459