GNU bug report logs - #75964
Switching the Emacs build to -Wswitch-enum in src/

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> protonmail.com>

Date: Fri, 31 Jan 2025 09:41:02 UTC

Severity: wishlist

Full log


Message #170 received at 75964 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Pip Cet <pipcet <at> protonmail.com>
Cc: acorallo <at> gnu.org, eggert <at> cs.ucla.edu, 75964 <at> debbugs.gnu.org,
 monnier <at> iro.umontreal.ca, stefankangas <at> gmail.com
Subject: Re: bug#75964: Switching the Emacs build to -Wswitch-enum in src/
Date: Tue, 04 Feb 2025 14:24:32 +0200
> Date: Mon, 03 Feb 2025 21:15:38 +0000
> From: Pip Cet <pipcet <at> protonmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, eggert <at> cs.ucla.edu, 75964 <at> debbugs.gnu.org, stefankangas <at> gmail.com, Andrea Corallo <acorallo <at> gnu.org>
> 
> "Stefan Monnier" <monnier <at> iro.umontreal.ca> writes:
> 
> >> enum ABC abc;
> >> switch (abc) {
> >> case A:
> >>   /* handle case A */
> >>   break;
> >> default:
> >>   /* we know this must be case C */
> >>   /* handle case C */
> >>   break;
> >> }
> >
> > I think this just suggests we should refrain from using `default:`
> 
> Switching over an enum without a default: label will generate
> fall-through code, for those cases in which the enum variable has a
> value that's not in the enumeration.

What is "fall-through code" in this context, and why is it bad that
the compiler will generate such code?




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.