GNU bug report logs - #75451
scratch/igc: Enable CHECK_STRUCTS

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Thu, 9 Jan 2025 03:58:02 UTC

Severity: wishlist

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


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

From: Pip Cet <pipcet <at> protonmail.com>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: Gerd Moellmann <gerd <at> gnu.org>, Paul Eggert <eggert <at> cs.ucla.edu>,
 Stefan Kangas <stefankangas <at> gmail.com>, 75451 <at> debbugs.gnu.org
Subject: Re: bug#75451: scratch/igc: Enable CHECK_STRUCTS
Date: Mon, 20 Jan 2025 09:00:12 +0000
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:

> Pip Cet <pipcet <at> protonmail.com> writes:
>
>>> Thanks, that's helpful.  Based on the above, I came up with the attached
>>> patch for pdumper.c.
>>
>> Let's introduce macros for the different cases, and use the same macro
>> in the same case, until GCC offers a fix.
>
> Pretty please not more macros.

Why not?  We need to distinguish "default case reached for some enum
values" and "default case reached only for non-enum values, warn if it's
reached for enum values".

I'm still not sure what the best way of expressing those two different
semantics of default labels is, and I don't think we should put the
"switch" or "default" in a macro, but it would involve some macros
because it relies on compiler features not always available (and #pragma
is horrible and shouldn't be used).

Think something like

enum ABC abc = whatever;

switch (abc)
  {
    case A:
    case B:
      handle();
      break;
    default:
      prove_or_warn (!in_enum (abc, enum ABC));
  }

in_enum would verify that a value is one of the enumerated values rather
than an invalid one.  prove_or_warn would produce a compiler warning if
its argument isn't __builtin_constant_p and true.  (The usual way to
make GCC do that is to call an undefined extern symbol if the argument
is false; if it's provably true, GCC won't try to link against the
symbol).

The problem is that it wouldn't work with "-O0", which makes
__builtin_constant_p useless.

But that's a minor change we need to make anyway: right now, "make"
builds Emacs just once and we look at the compiler warnings from that
run.  With the static analyzer and things like that, we need a separate
make target for extra compiler warnings.  (We should run this by
default, of course).

(That would also solve the texinfo/@xref problem: texinfo apparently
cannot generate the warning, so let's make that new target check for
invalid @xrefs using some simple Elisp).

Pip





This bug report was last modified 106 days ago.

Previous Next


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