https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119718
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to lucier from comment #6) > If musttail is going to change which tail calls are optimized, I really > think we need a warning flag that will have GCC give a warning when musttail > is not used on a tail call, -foptimize-sibling-calls is given, and a tail > call is not optimized for whatever reason. I don't see how such warning could work. With the exception of musttail attribute, tail call optimization is a best effort optimization, if all conditions are met including most importantly returning the value from the callee to the caller with no value modifications (or some limited ones for tail recursions), then it is optimized. But it doesn't really care if it is in the source code written as return foo (1, 2, 3); or int a = foo (1, 2, 3); a += 10; a -= 10; return a; or for call returning void return bar (); or bar (); return; or bar (); a ^= 10; a ^= 10; return; etc. We can't just warn on all calls, most of them obviously aren't in tail call positions and such warning would have extreme amounts of false positives.