https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110437
Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org --- Comment #11 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to Jan Žižka from comment #3) > Good thanks for pointer and clarification. > > Is there some reason this cannot be caught during compile time already? I > mean the warning should be an error maybe? It would be much easier to fix in > legacy code. Note that -Werror=return-type cannot be the default because... int f(int a) { if (a == 1) return 0xdead; else if (a == 42) return 0xbeef; } is perfectly legal if the caller doesn't pass anything other than 1 or 42 to f. So we cannot just reject it at the compile time, we can only issue a warning. And generally there is no way to determine if an "unsupported" value is passed to f at compile time because doing so will need to solve the halting problem.