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.

Reply via email to