https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71743
Bug ID: 71743 Summary: return with no value cannot be ignored [Possible regression or undocumented change on https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Warning-O ptions.html#Warning-Options] Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bastien.penavayre at epitech dot eu Target Milestone: --- Created attachment 38823 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38823&action=edit gcc-4.9 -v -c test.c Hi, So since gcc-5, in manual at the warning section: https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Warning-Options.html#Warning-Options and https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/Warning-Options.html#Warning-Options It's stated that: "-Wreturn-type ... Also warn about any return statement with no return value in a function whose return type is not void ... , and about a return statement with an expression in a function whose return type is void." The issue here is that this is not true as the following code still warns: int func() { #pragma GCC diagnostic ignored "-Wreturn-type" return ; } This one also : void func() { #pragma GCC diagnostic ignored "-Wreturn-type" return 42; } The only case where ignoring -Wreturn-type works is when : "falling off the end of the function body is considered returning without a value". The first test worked as expected before gcc-5 and warns since then. Before gcc-5 the second test warns as expected as the "a return statement with an expression in a function whose return type is void" wasn't yet part of the manual.