Skip to content

Commit 38ca78d

Browse files
peffgitster
authored andcommitted
config.mak.dev: enable -Wunreachable-code
Having the compiler point out unreachable code can help avoid bugs, like the one discussed in: https://lore.kernel.org/git/[email protected]/ In that case it was found by Coverity, but finding it earlier saves everybody time and effort. We can use -Wunreachable-code to get some help from the compiler here. Interestingly, this is a noop in gcc. It was a real warning up until gcc 4.x, when it was removed for being too flaky, but they left the command-line option to avoid breaking users. See: https://stackoverflow.com/questions/17249934/why-does-gcc-not-warn-for-unreachable-code However, clang does implement this option, and it finds the case mentioned above (and no other cases within the code base). And since we run clang in several of our CI jobs, that's enough to get an early warning of breakage. We could enable it only for clang, but since gcc is happy to ignore it, it's simpler to just turn it on for all developer builds. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c21db3 commit 38ca78d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

config.mak.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ DEVELOPER_CFLAGS += -Wunused
3939
DEVELOPER_CFLAGS += -Wvla
4040
DEVELOPER_CFLAGS += -Wwrite-strings
4141
DEVELOPER_CFLAGS += -fno-common
42+
DEVELOPER_CFLAGS += -Wunreachable-code
4243

4344
ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
4445
DEVELOPER_CFLAGS += -Wtautological-constant-out-of-range-compare

0 commit comments

Comments
 (0)