Subject: Re: [PATCH] config.mak.dev: enable -Wunreachable-code

From: Junio C Hamano <[email-masked]>
Date: Fri, 14 Mar 2025 10:15:51 -0700

Jeff King <[email-masked]> writes:

> That would use the flag in more situations (blocking the known-bad case,
> rather than enabling it in a known-good one). It might hit more false
> positives, but I'd rather experiment in that direction and see if
> anybody setting DEVELOPER=1 complains.

Good.

> After all, in either case it is
> still a big question of whether this is the only false positive we'll
> see, or if this is opening up a can of worms. So I consider it all
> kind-of exploratory.

Again, good.

> So that patch could look like this (on top of what you've queued already
> in jk/use-wunreachable-code-for-devs).

> +
> +# There are false positives for unreachable code related to system
> +# functions on macOS.
> +ifneq ($(uname_S),Darwin)
>  DEVELOPER_CFLAGS += -Wunreachable-code
> +endif

One possible downside of this is that we would not know when their
compiler stops giving the "false positive" and becomes as usuable as
other platforms (oh, it came out unintendedly harsh---it could be
that the situation is that their compiler is doing the right thing,
and the right thing is a bit inconvenient for this codebase).

Unless diligent volunteers with macOS step up to do trial builds
with the option when they notice that their toolchain or OS header
files got upgraded, that is.

But other than that, I am fine with this.  Let's have this for some
time to see how much problems (false positives) our newly added code
would get to judge if it is worth our time to deal with them.

Thanks.