http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517
Bug ID: 60517 Summary: warning/error for taking address of member of a temporary object Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: manu at gcc dot gnu.org class B { public: double x[2]; }; class A { B b; public: B getB(void) { return b; } }; double foo(A a) { double * x = &(a.getB().x[0]); return x[0]; } In the code above, x is not pointing to anything useful. I am not sure how hard would be to diagnose this, but it would be nice if it was possible. It would have saved me a few hours of bug-hunting today.