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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> Because of the C++ vs. C differences, -Wreturn-type warning is on by default
> in C++ while it is only included in -Wall for C, users just shouldn't ignore
> this warning unless it is really impossible to reach it at runtime.

If you find it too easy to ignore those warnings, use -Werror=return-type to
prevent such bugs from compiling. That can't be the default though, because
it's possible to get false positives, or warnings for branches that GCC thinks
are reachable (and so the warning is correct) but which are never actually
reached at runtime given the possible function inputs. For the cases where the
diagnostic can safely be ignored, you can explicitly annotate the code with
__builtin_unreachable() or std::abort() or similar.

Reply via email to