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

From: Eli Zaretskii <[email-masked]>
Date: Wed, 05 Feb 2025 14:15:17 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked],
>   [email-masked],  [email-masked]
> Date: Tue, 04 Feb 2025 15:45:36 -0500
> 
> > So you want a device that would abort for unexpected values?
> 
> I want the compiler to consider this case as an error, rather than
> a defined "this is an empty statement".

Which part of your code is the error you want the compiler to flag?
the cast to enum of a value that is outside of the enum, or the fact
that not all the valid values of the enum are mentioned explicitly in
the switch, so some will fall through?

> > Then why use switch at all?
> 
> Because you want to perform various operations depending on the value of
> the enum (admittedly, in my example I performed the same op on all
> values, but that's because I typed it by hand and got lazy).

An assertion followed by a switch should fit the bill, no?