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: unassig...@gcc.gnu.org ReportedBy: ja...@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; }