gcc no "unreachable code" warning?
-
int func() { return 1; // further statements // and perhaps a return 2; }
gcc
9.3.0. I compile with-Wall
. No warning after the firstreturn
, nor in the clang-chacking Qt Creator code editor.I expected it would warn. I have searched web and over many years it seems some older
-Wunreachable-code
or similar has been deprecated/removed. So there is nothing now for this? Or, is there some extra warning I should be passing? Were you peeps aware of this and quite happy compiling your code without a warning for such an obviously wrong case? -
-
@Christian-Ehrlicher
Yes, but see the complainant in the first post at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46476. I feel his pain.I ran
int func() { return 1; return 2; }
through a variety of the compilers at that Compiler Explorer/godbolt. Not one of them warned. Is it that we cannot set/adjust any compilation warnings there? I know you won't agree, but it's just sad that none of them offer to warn on the above :) :(