https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108476
Bug ID: 108476 Summary: Please turn -Wreturn-type on by default for C Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alexhenrie24 at gmail dot com Target Milestone: --- According to the documentation, -Wreturn-type does the following: "Warn whenever a function is defined with a return type that defaults to int. Also warn about any return statement with no return value in a function whose return type is not void (falling off the end of the function body is considered returning without a value)." https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html I feel strongly that gcc should turn on -Wreturn-type by default for the following reasons: * Not specifying the return value of a function that returns a non-void value is almost always a bug. * C99 and later do not allow declaring or defining a function without a return type, so there's a good chance that code that omits the return type will break when used with other compilers. * GCC already turns the warning on by default for C++, and all but the most educated of users do not expect C and C++ to be different in this regard, so it gives a false sense of security when no such warnings appear when compiling C code. * Clang already turns the warning on by default for both C and C++, which goes to show that the warning does not come up much in practice. I've personally been bitten by forgetting to return a value from a function, so I hope you will agree that -Wreturn-type is a sensible default to help spot bugs sooner.