[Bug c++/59813] tail-call elimintation didn't fired with left-shift of char to cout

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 15 07:23:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59813

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you only care about tail recursion and not tail call optimization, perhaps,
but either solution would be very dumb.  We now have var ={v} {CLOBBER}; stmts,
even if those vars escape and are address taken, if there is a clobber stmt for
those vars on every path from the escape point to the tail call candidate, we
could perform tail recursion or tail call optimization, what we are really
after is that the address of no automatic variable from the current function
can escape to the tail recursion/call candidate.
As in:
void bar (char *);
void
foo (char *p)
{
  char c;
  bar (&c);
  bar (NULL); // We can't tail call optimize this
}

void
baz (char *p)
{
  {
    char c;
    bar (&c);
  }
  bar (NULL); // We could tail call optimize this
}



More information about the Gcc-bugs mailing list