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

            Bug ID: 125874
           Summary: gcc is incompatible with clang when using musttail and
                    setjmp
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmelcr at gcc dot gnu.org
            Blocks: 125576
  Target Milestone: ---

Hi,
GCC rejects the following code, while clang accepts it:

```
jmelcr @ tumbleweed in ~ $ cat musttail.c
#include <setjmp.h>

jmp_buf a;

int c(int x) {
  if (x < 7)
    return x % 4;

  setjmp(a);

  __attribute__((musttail)) return c(x - 1);
}
jmelcr @ tumbleweed in ~ $ gcc -c musttail.c
musttail.c: In function ā€˜c’:
musttail.c:11:36: error: cannot tail-call: caller uses setjmp
   11 |   __attribute__((musttail)) return c(x - 1);
      |                                    ^~~~~~~~
jmelcr @ tumbleweed in ~ $ clang -c musttail.c
jmelcr @ tumbleweed in ~ $
```

The example is of course arbitrary, but it comes up in real code (e.g. the PHP
interpreter). I `think` that our behavior is correct and that it should be
fixed in clang instead, but I am filing this just to be sure.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125576
[Bug 125576] [meta-bug] clang/LLVM compatibility

Reply via email to