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

            Bug ID: 123059
           Summary: [[musttail]] on normal call in void function is
                    silently ignored
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hanicka at hanicka dot net
  Target Milestone: ---

https://compiler-explorer.com/z/1s65K5hze

When I use [[gnu::musttail]] here:

```c++
void g();

void f() {
    [[gnu::musttail]] g();
}
```

The attribute is silently ignored, and emitted code contains (with -O0)

```
f():
        push    rbp
        mov     rbp, rsp
        call    g()
        nop
        pop     rbp
        ret
```

I would expect one of following behaviors:

A) error for using the attribute anywhere but infront of a return statement
B) make a tail-recursion to work like if there was a `return` if it's a last
function call in a void returning function

Reply via email to