GNU bug report logs -
#75964
Switching the Emacs build to -Wswitch-enum in src/
Previous Next
Full log
Message #206 received at 75964 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: pipcet <at> protonmail.com, eggert <at> cs.ucla.edu, 75964 <at> debbugs.gnu.org,
> stefankangas <at> gmail.com, acorallo <at> gnu.org
> 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?
This bug report was last modified 127 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.