http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60297
Bug ID: 60297 Summary: Temporary lifetime not extended by reference bound to POD member Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: potswa at mac dot com The resolution to DR 1651 seems inconsistently applied. This program should print "check" before "destroy", but if the reference is bound to member "i" instead of "np" the lifetime is not extended. #include <iostream> struct notpod { ~notpod() {} }; struct noisy { ~noisy() { std::cout << "destroy\n"; } }; struct cont { noisy o; notpod np; int i; }; int main() { { notpod && q = cont().np; std::cout << "check\n"; } // cont::~cont here { int && i = cont().i; // cont::~cont here; i is dangling. std::cout << "check\n"; } } The problem may be broader than DR 1651 because the results are the same if "const &" is substituted for "&&". (Note, I submitted a trivial, somewhat similar bug yesterday but this issue is completely unrelated, and it's "for real.")