This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/61493] [4.10 Regression] Bug exposed by speculative devirtualizing
- From: "wmi at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Jun 2014 16:25:15 +0000
- Subject: [Bug tree-optimization/61493] [4.10 Regression] Bug exposed by speculative devirtualizing
- Auto-submitted: auto-generated
- References: <bug-61493-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61493
wmi at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from wmi at google dot com ---
This is a source problem. So close the bug.
void foo(FST *fst) {
const PAIR &final_pair = fst->Final().getpair();
if (final_pair == global_pair)
__builtin_printf("equal\n");
else
__builtin_printf("not equal\n");
return;
}
The life time of the temporary object generated by fst->Final() will not be
extended after the statement generating it, according to the following rule :
a temporary bound to a return value of a function in a return statement is not
extended: it is destroyed immediately at the end of the return expression. Such
function always returns a dangling reference.
(http://en.cppreference.com/w/cpp/language/reference_initialization)
So it is meaningless to access final_pair afterwards.