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

            Bug ID: 124532
           Summary: musttail: syntactic restriction too tight
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wingo at pobox dot com
  Target Milestone: ---

Consider:

```
$ gcc --version
gcc (GCC) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat /tmp/test1.c
extern int f(void);

static int g(void) {
  [[gnu::musttail]] return f();
  return 42;
}
$ gcc -o /tmp/test1.o -c /tmp/test1.c
/tmp/test1.c: In function ā€˜g’:
/tmp/test1.c:5:10: error: cannot tail-call: return value must be a call
    5 |   return 42;
      |          ^~
```

However, this works:
```
static int g(void) {
  if (1) [[gnu::musttail]] return f();
  return 42;
}
```

Reply via email to