This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60517] warning/error for taking address of member of a temporary object
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Mar 2014 15:41:16 +0000
- Subject: [Bug c++/60517] warning/error for taking address of member of a temporary object
- Auto-submitted: auto-generated
- References: <bug-60517-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517
--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #5)
> I would need a different (middle-end) warning that
> detects return &local_var,
To confirm this, I looked at the last dangling reference I debugged, recompiled
it with -O3 -fkeep-inline-functions, and a grep for "return &" in the
.optimized dump showed:
return &one;
return &one;
return &D.495451.c_;
(where "one" is a global variable, but D.495451 is a local variable)
so even this trivial version of the warning would be useful.