https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119492

            Bug ID: 119492
           Summary: missing tail call due to address of the argument taken
                    but NOT escaping
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: FIXME, missed-optimization, tail-call
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
__attribute__((noinline)) void f(int *a)
{
  *a = 0;
}

int l(int);

int h(int a)
{
  f(&a);
  [[clang::musttail]] 
  return l(a);
}
```

This fails due to:
<source>:12:11: error: cannot tail-call: address of caller arguments taken

Which is from:
```
  /* ??? It is OK if the argument of a function is taken in some cases,
     but not in all cases.  See PR15387 and PR19616.  Revisit for 4.1.  */
  for (param = DECL_ARGUMENTS (current_function_decl);
       param;
       param = DECL_CHAIN (param))
    if (TREE_ADDRESSABLE (param))
      {
        maybe_error_musttail (call, _("address of caller arguments taken"),
                              diag_musttail);
        return false;
      }
```

Reply via email to