This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70259] New: [6 Regression] -flifetime-dse=2 bug with empty bases
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Mar 2016 17:38:45 +0000
- Subject: [Bug c++/70259] New: [6 Regression] -flifetime-dse=2 bug with empty bases
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70259
Bug ID: 70259
Summary: [6 Regression] -flifetime-dse=2 bug with empty bases
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
struct A { A () : a (true) {} bool a; ~A () {} };
struct B { };
struct C : B { C () {} ~C () {} };
struct D { D () : d (true) {} bool d; ~D () {} };
struct E : public A, C, D { E () : e (true) {} bool e; ~E () {} };
int
main ()
{
E e;
if (!e.a || !e.d || !e.e)
__builtin_abort ();
}
is miscompiled with -O2, works with -O2 -flifetime-dse=1 or -O2
-fno-lifetime-dse.
The problem is that the C::C ctor emits a {CLOBBER} for 1 byte, even when C is
empty class and can overlap other fields. Similarly the {CLOBBER} we emit in
the dtor is 1 byte and can overlap other fields, so in theory one could try to
construct a testcase that would fail already with GCC 5.x or 4.9?
Less reduced testcase for the same issue:
#include <tuple>
struct P1 { } _1;
struct testStruct;
struct _Bind
{
std::tuple<testStruct*, P1, bool> _M_bound_args;
explicit _Bind(testStruct* arg)
: _M_bound_args(arg, _1, true)
{ }
bool
operator()()
{
return std::get<2>(_M_bound_args);
}
};
struct testStruct {
void runme() {
_Bind c(this);
if ( c() == false )
__builtin_abort();
}
};
int main() {
testStruct s;
s.runme();
}