Subject: bug#75964: Switching the Emacs build to -Wswitch-enum in src/

From: Pip Cet <[email-masked]>
Date: Sun, 02 Feb 2025 09:26:48 +0000

"Eli Zaretskii" <[email-masked]> writes:

>> Cc: [email-masked], Stefan Kangas <[email-masked]>
>> Date: Sun, 02 Feb 2025 08:39:11 +0000
>> From:  Pip Cet via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>>
>> I think we should enable -Wswitch-enum now, and expect it to generate
>> more warnings in the future.
>
> I'm not sure I understand what "in the future" means here, but please

Future GCC versions may and will add warnings about cases that they
currently fail to warn about, for the same switch.  I don't think we can
change that.

> don't add warning options that will generate warnings while compiling
> the current sources; if they do, either the source code should be
> fixed to avoid the warnings before the warning option is turned on by
> default, or the warning option should not be turned on by default.  We

I agree.  Making GCC emit more warnings by changing its configuration
and then telling others to fix them isn't right.

> strive to have the current sources compile cleanly with the default
> warning options, so that any warning draws attention and is fixed
> ASAP; thus, having compilation warnings routinely emitted that cannot
> be easily fixed is not a good idea because that causes people to
> ignore warnings.

Agreed, as far as changing Emacs goes.  GCC, of course, can change
independently.

(In this case, it's unlikely I'll submit a GCC patch that produces
fixable warning in Emacs, but other projects may not be so lucky).

> Apologies if the above is not relevant to what you were discussing
> regarding adding warning options.

I think it's highly relevant: I proposed several ways of adding the
warning options:  one file at a time, #pragma'd out, or enabled globally
and only merged once we can fix, at least, the common build systems.
Simply enabling them globally and waiting for someone else to fix the
warnings only leads to other warnings being missed.

Is that an accurate summary?  If you have another option, or a
preference between the three options I mentioned, would you mind sharing
it?

Thanks!

Pip