This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81420] New: When a reference is bound to a member in the base of a temporary, lifetime of the temporary is not extended
- From: "ryan.brown at ableton dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Jul 2017 19:11:12 +0000
- Subject: [Bug c++/81420] New: When a reference is bound to a member in the base of a temporary, lifetime of the temporary is not extended
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81420
Bug ID: 81420
Summary: When a reference is bound to a member in the base of a
temporary, lifetime of the temporary is not extended
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ryan.brown at ableton dot com
Target Milestone: ---
This is a followup to bug #54293. The incorrect behavior can be seen by
modifying the test introduced for that bug [0] to use a base class:
int d;
struct A
{
int i;
~A() { ++d; };
};
struct B : A {};
int main()
{
{
const int &r = B().i;
if (d != 0)
return 1;
}
if (d != 1)
return 1;
}
This test passes for clang HEAD and fails for GCC HEAD.
[0]
https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/testsuite/g%2B%2B.dg/init/ref19.C?view=markup&pathrev=240819