This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49528] New: g++ fails to destroy temporary object when subobject is used to initialize a reference
- From: "jason at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 25 Jun 2011 03:33:23 +0000
- Subject: [Bug c++/49528] New: g++ fails to destroy temporary object when subobject is used to initialize a reference
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49528
Summary: g++ fails to destroy temporary object when subobject
is used to initialize a reference
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jason@gcc.gnu.org
I believe that r should point to a temporary int and the A temporary destroyed
at the end of the declaration statement rather than have its lifetime extended
to the end of the block. In any case, never destroying it is clearly broken.
int d;
struct A
{
int i;
~A() { ++d; };
};
int main()
{
{ const int &r = A().i; }
if (d != 1)
return 1;
}