Subject: bug#75451: scratch/igc: Enable CHECK_STRUCTS

From: Gerd Möllmann <[email-masked]>
Date: Fri, 10 Jan 2025 19:58:09 +0100

Stefan Kangas <[email-masked]> writes:

> commit 44a39e3e761c0774cd1bb9360db7f49e1d66ec06
> Author: Paul Eggert <[email-masked]>
> Date:   Tue Apr 9 15:42:10 2019 -0700
>
>     Remove dmpstruct.h
>
>     The hassles of updating the dmpstruct.h-using code bit me again.
>     These updates are more trouble than they’re worth.  See:
>     https://lists.gnu.org/r/emacs-devel/2019-03/msg00122.html
>     As I’m the main person who’s made changes in this area since
>     dmpstruct.h was introduced, I’m the most motivated to clean up
>     the situation.
>
> I'm curios to know what is the experience while developing scratch/igc:
> have these checks been very helpful?

It was helpful for me, in the pdumper, because I hadn't activated it in
igc.c. Reason for it being that I have some other differences in my fork,
like CL packages :-).

> Meanwhile, for enums, I'm wondering if something like this wouldn't make
> more sense?  (Or perhaps in addition to CHECK_STRUCTS.  Hmm.)
>
> diff --git a/src/igc.c b/src/igc.c
> index 37929765522..6c8ad55878c 100644
> --- a/src/igc.c
> +++ b/src/igc.c
> @@ -2770,6 +2776,8 @@ fix_vector (mps_ss_t ss, struct Lisp_Vector *v)
>  #endif
>  	IGC_FIX_CALL_FN (ss, struct Lisp_Vector, v, fix_vectorlike);
>  	break;
> +      default:
> +	emacs_abort ();
>        }
>    }
>    MPS_SCAN_END (ss);

I'm personally a big fan of exhaustive switches, as igc.c might show
:-). I find they make it a lot easier to find all relevant places when
adding enums. And I think the default case would work against that.