This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/61493] [4.10 Regression] Bug exposed by speculative devirtualizing


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]