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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I already explained this on reddit, and it's already explained in PR 43943.

There are programs that are valid and must not give an error.

    int f() { }
    int main() { }

This never calls f() so there is no problem. -Werror=return-type would fail to
compile this valid program.

    int g(bool b) { if (b) return 1; }
    int main() { g(true); }

This program calls g(true) which is OK, it never calls g(false).
-Werror=return-type would fail to compile this valid program.

The C++ standard says these programs must be accepted without errors. What GCC
does is allow you to compile broken code, but it warns, and since GCC 13 it
tries to prevent completely unpredictable undefined behaviour if you
accidentally do fall off the end of a function without returning.

Reply via email to