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 #119 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,
 stefankangas <at> gmail.com, monnier <at> iro.umontreal.ca
Subject: Re: bug#75964: Switching the Emacs build to -Wswitch-enum in src/
Date: Sun, 02 Feb 2025 19:35:41 +0200
> Date: Sun, 02 Feb 2025 17:02:04 +0000
> From: Pip Cet <pipcet <at> protonmail.com>
> Cc: eggert <at> cs.ucla.edu, 75964 <at> debbugs.gnu.org, stefankangas <at> gmail.com, acorallo <at> gnu.org, monnier <at> iro.umontreal.ca
> 
> "Eli Zaretskii" <eliz <at> gnu.org> writes:
> 
> > This is an example of code where some value of an enumeration need
> > special handling, and the rest don't need any handling at all.  IMO,
> > we should ask ourselves what are we trying to accomplish by spelling
> > out all of the "other" values instead of just 'default'?  If we only
> > care for a handful of values, what kind of errors could slip us if we
> > use 'default'?
> 
> As someone who's not very familiar with the bidi code, I would feel most
> comfortable if this switch, with all cases, were in an inline function
> which decides whether we set l2r_seen, r2l_seen, or neither, in this
> context.  Ideally, in my case, with further comments, though trying to
> understand this code without studying the Unicode Bidirectional
> Algorithm will always be foolish...

The bidi.c code is in many places in the shape it is because it tries
to closely follow the description in the UBA, so as to make the
understanding of what the code does easier without drowning it in
comments.

If the goal here is to make sure we never miss a type is to invent a
new category, which includes only the 4 types mentioned in the switch,
and then do the switch only for that category.




This bug report was last modified 128 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.