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

--- Comment #10 from Lukas Grätz <lukas.gra...@tu-darmstadt.de> ---
(In reply to Andi Kleen from comment #8)
> ><source>:3:30: error: cannot tail-call: volatile function type
> 
> I wonder how that happened. It looks like a bug. volatile functions should
> be rejected elsewhere and there is no volatile in the test case.
> 
> Maybe some tree bit encoding gets confused?
> 
> Should reopen the bug just for this.

I guess there are two solutions:

First, to allow no-return function calls with musttail attribute. Although it
is currently not supported and tail-calls for no-return functions are not done
in general because of debugging, it should be OK if the attribute is used
explicitly.

There was another issue referenced in 10837:
https://gcc.gnu.org/pipermail/gcc-bugs/2000-October/040396.html
I tested this (by explicitly given the exit() signature without noreturn
attribute):

extern void exit(int);
void main() {
   [[gnu::musttail]] return exit(0);
}

gcc exitsibcall.c -o exitsibcall
./exitsibcall

I checked it. At least on my x86-64, I could not observe the reported garbage
exit status (it exits with status 0 or whatever we pass to exit()). I have not
tested it on i686, but with -m32 I get an error "target is not able to optimize
the call into a sibling call".

The second solution is to keep it as-is and just fix the error message to
something more meaningful like "cannot tail-call noreturn functions". But I see
no reason in doing so, unless above issue manifests in another configuration.
Have I missed something?

Reply via email to