https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96057
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|NEW |RESOLVED --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- That's because the -Wreturn-type diagnostic happens after we remove unused functions which we only do at -O1+: t.c: At global scope: t.c:2:9: warning: 'int {anonymous}::foo()' defined but not used [-Wunused-function] 2 | int foo() { 1 ? 0 : throw 0 ; } | ^~~ which in turn is because the function is local (in an anonymous namespace). Likely GCC 4.1 removed the function only later. IMHO a WONTFIX, sorry.