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

--- Comment #29 from Lukas Grätz <lukas.gra...@tu-darmstadt.de> ---
(In reply to Josh Haberman from comment #25)
> As a result, I now agree with you that `musttail` addresses the complaint in
> this bug.  While it is odd and unexpected that `noreturn` will inhibit tail
> calls, I agree that `musttail` appears to override this behavior, providing
> an escape hatch for users who want tail calls on `noreturn` functions.
> 
> It is somewhat unfortunate that this requires the attribute to be at every
> call site,  instead of on the `noreturn` function itself, but at least it is 
> possible.

Having a musttail attribute on the signature of the noreturn function itself is
probably not a good idea, if you think about it more. Take the function
abort(): If you want to change the signature, you need to change the standard
library headers. And if you wrote a noreturn function like temp2() yourself, it
is still not a good idea to force musttail on it, I would say. Because this is
a big restriction on how your function can be called.

Another solution would be to add an optimization like -fno-proper-noreturn-bt.
This option would globally overwrite the behavior and allow tail-calling
noreturn functions. If you really have a convincing use case where such
optimization is needed (I have none), file a feature request.

Reply via email to