Subject: Re: bug#75964: Switching the Emacs build to -Wswitch-enum in src/

From: Pip Cet <[email-masked]>
Date: Fri, 31 Jan 2025 14:11:00 +0000

"Robert Pluim" <[email-masked]> writes:

>>>>>> On Fri, 31 Jan 2025 12:48:02 +0000, Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> said:
>     >>
>     >> That might be fine when the enumeration is ours, but if it comes from
>     >> a system header file, the only practical option is 0, with 1 being a
>     >> very distant second (having a switch with many dozens of values is
>     >> hardly a good thing).
>
>     Pip> You're talking about a different problem then.  If an
>     Pip> externally-controlled enum is expected to grow, we want a compiler
>     Pip> warning to let us know when this happens, but we also need a default:
>     Pip> handler that deals with this case.  So the right option is that we don't
>     Pip> need any of the extra options, the default behaviour will be just fine.
>
> Both gcc and clang support case ranges these days, so handling large
> enums should not be a problem.

Thanks! Indeed, in many cases enums are ordered logically so we can use
case ranges.  Here's pdumper.c, which illustrates this:

(first three patches revert recent attempts to get more or fewer
warnings):

>From 2fd1752051e7b7b1a3a51a659277bdc0e37aca8f Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Subject: [PATCH 1/4] Revert "; * src/pdumper.c (dump_do_fixup): Pacify GCC."

This reverts commit a99ba59aa02ef8cfd314737950b6cd8d97015925.
---
 src/pdumper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index bfa790b963a..9f0447eb5aa 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -3990,7 +3990,7 @@ dump_do_fixup (struct dump_context *ctx,
   Lisp_Object arg = dump_pop (&fixup);
   eassert (NILP (fixup));
   dump_seek (ctx, dump_fixup_offset);
-  intptr_t dump_value UNINIT;
+  intptr_t dump_value;
   bool do_write = true;
   switch (type)
     {
-- 
2.48.1

>From a56416559996359570ff70c8749a5972fb9e14d4 Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Subject: [PATCH 2/4] Revert "Pacify -Wanalyzer-use-of-uninitialized-value"

This reverts commit 1ed769a3cb753a86badba8a2878fa788a6fdc1f8.
---
 src/pdumper.c | 91 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 62 insertions(+), 29 deletions(-)

diff --git a/src/pdumper.c b/src/pdumper.c
index 9f0447eb5aa..45a44db0243 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2292,12 +2292,11 @@ dump_float (struct dump_context *ctx, const struct Lisp_Float *lfloat)
 }
 
 static dump_off
-dump_fwd_int (struct dump_context *ctx, void const *fwdptr)
+dump_fwd_int (struct dump_context *ctx, const struct Lisp_Intfwd *intfwd)
 {
 #if CHECK_STRUCTS && !defined HASH_Lisp_Intfwd_4D887A7387
 # error "Lisp_Intfwd changed. See CHECK_STRUCTS comment in config.h."
 #endif
-  struct Lisp_Intfwd const *intfwd = fwdptr;
   dump_emacs_reloc_immediate_intmax_t (ctx, intfwd->intvar, *intfwd->intvar);
   struct Lisp_Intfwd out;
   dump_object_start (ctx, &out, sizeof (out));
@@ -2307,12 +2306,11 @@ dump_fwd_int (struct dump_context *ctx, void const *fwdptr)
 }
 
 static dump_off
-dump_fwd_bool (struct dump_context *ctx, void const *fwdptr)
+dump_fwd_bool (struct dump_context *ctx, const struct Lisp_Boolfwd *boolfwd)
 {
 #if CHECK_STRUCTS && !defined (HASH_Lisp_Boolfwd_0EA1C7ADCC)
 # error "Lisp_Boolfwd changed. See CHECK_STRUCTS comment in config.h."
 #endif
-  struct Lisp_Boolfwd const *boolfwd = fwdptr;
   dump_emacs_reloc_immediate_bool (ctx, boolfwd->boolvar, *boolfwd->boolvar);
   struct Lisp_Boolfwd out;
   dump_object_start (ctx, &out, sizeof (out));
@@ -2322,12 +2320,11 @@ dump_fwd_bool (struct dump_context *ctx, void const *fwdptr)
 }
 
 static dump_off
-dump_fwd_obj (struct dump_context *ctx, void const *fwdptr)
+dump_fwd_obj (struct dump_context *ctx, const struct Lisp_Objfwd *objfwd)
 {
 #if CHECK_STRUCTS && !defined (HASH_Lisp_Objfwd_45D3E513DC)
 # error "Lisp_Objfwd changed. See CHECK_STRUCTS comment in config.h."
 #endif
-  struct Lisp_Objfwd const *objfwd = fwdptr;
   if (NILP (Fgethash (dump_off_to_lisp (emacs_offset (objfwd->objvar)),
                       ctx->staticpro_table,
                       Qnil)))
@@ -2340,12 +2337,12 @@ dump_fwd_obj (struct dump_context *ctx, void const *fwdptr)
 }
 
 static dump_off
-dump_fwd_buffer_obj (struct dump_context *ctx, void const *fwdptr)
+dump_fwd_buffer_obj (struct dump_context *ctx,
+                     const struct Lisp_Buffer_Objfwd *buffer_objfwd)
 {
 #if CHECK_STRUCTS && !defined (HASH_Lisp_Buffer_Objfwd_611EBD13FF)
 # error "Lisp_Buffer_Objfwd changed. See CHECK_STRUCTS comment in config.h."
 #endif
-  struct Lisp_Buffer_Objfwd const *buffer_objfwd = fwdptr;
   struct Lisp_Buffer_Objfwd out;
   dump_object_start (ctx, &out, sizeof (out));
   DUMP_FIELD_COPY (&out, buffer_objfwd, type);
@@ -2356,12 +2353,12 @@ dump_fwd_buffer_obj (struct dump_context *ctx, void const *fwdptr)
 }
 
 static dump_off
-dump_fwd_kboard_obj (struct dump_context *ctx, void const *fwdptr)
+dump_fwd_kboard_obj (struct dump_context *ctx,
+                     const struct Lisp_Kboard_Objfwd *kboard_objfwd)
 {
 #if CHECK_STRUCTS && !defined (HASH_Lisp_Kboard_Objfwd_CAA7E71069)
 # error "Lisp_Intfwd changed. See CHECK_STRUCTS comment in config.h."
 #endif
-  struct Lisp_Kboard_Objfwd const *kboard_objfwd = fwdptr;
   struct Lisp_Kboard_Objfwd out;
   dump_object_start (ctx, &out, sizeof (out));
   DUMP_FIELD_COPY (&out, kboard_objfwd, type);
@@ -2375,16 +2372,29 @@ dump_fwd (struct dump_context *ctx, lispfwd fwd)
 #if CHECK_STRUCTS && !defined (HASH_Lisp_Fwd_Type_9CBA6EE55E)
 # error "Lisp_Fwd_Type changed. See CHECK_STRUCTS comment in config.h."
 #endif
-  typedef dump_off (*dump_fwd_fnptr) (struct dump_context *, void const *);
-  static dump_fwd_fnptr const dump_fwd_table[] = {
-    [Lisp_Fwd_Int] = dump_fwd_int,
-    [Lisp_Fwd_Bool] = dump_fwd_bool,
-    [Lisp_Fwd_Obj] = dump_fwd_obj,
-    [Lisp_Fwd_Buffer_Obj] = dump_fwd_buffer_obj,
-    [Lisp_Fwd_Kboard_Obj] = dump_fwd_kboard_obj,
-  };
+  void const *p = fwd.fwdptr;
+  dump_off offset;
 
-  return dump_fwd_table[XFWDTYPE (fwd)] (ctx, fwd.fwdptr);
+  switch (XFWDTYPE (fwd))
+    {
+    case Lisp_Fwd_Int:
+      offset = dump_fwd_int (ctx, p);
+      break;
+    case Lisp_Fwd_Bool:
+      offset = dump_fwd_bool (ctx, p);
+      break;
+    case Lisp_Fwd_Obj:
+      offset = dump_fwd_obj (ctx, p);
+      break;
+    case Lisp_Fwd_Buffer_Obj:
+      offset = dump_fwd_buffer_obj (ctx, p);
+      break;
+    case Lisp_Fwd_Kboard_Obj:
+      offset = dump_fwd_kboard_obj (ctx, p);
+      break;
+    }
+
+  return offset;
 }
 
 static dump_off
@@ -4534,19 +4544,26 @@ dump_anonymous_allocate_w32 (void *base,
 #  define MAP_ANONYMOUS MAP_ANON
 # endif
 
-static int const mem_prot_posix_table[] = {
-  [DUMP_MEMORY_ACCESS_NONE] = PROT_NONE,
-  [DUMP_MEMORY_ACCESS_READ] = PROT_READ,
-  [DUMP_MEMORY_ACCESS_READWRITE] = PROT_READ | PROT_WRITE,
-};
-
 static void *
 dump_anonymous_allocate_posix (void *base,
                                size_t size,
                                enum dump_memory_protection protection)
 {
   void *ret;
-  int mem_prot = mem_prot_posix_table[protection];
+  int mem_prot;
+
+  switch (protection)
+    {
+    case DUMP_MEMORY_ACCESS_NONE:
+      mem_prot = PROT_NONE;
+      break;
+    case DUMP_MEMORY_ACCESS_READ:
+      mem_prot = PROT_READ;
+      break;
+    case DUMP_MEMORY_ACCESS_READWRITE:
+      mem_prot = PROT_READ | PROT_WRITE;
+      break;
+    }
 
   int mem_flags = MAP_PRIVATE | MAP_ANONYMOUS;
   if (mem_prot != PROT_NONE)
@@ -4690,9 +4707,25 @@ dump_map_file_posix (void *base, int fd, off_t offset, size_t size,
 		     enum dump_memory_protection protection)
 {
   void *ret;
-  int mem_prot = mem_prot_posix_table[protection];
-  int mem_flags = (protection == DUMP_MEMORY_ACCESS_READWRITE
-		   ? MAP_PRIVATE : MAP_SHARED);
+  int mem_prot;
+  int mem_flags;
+
+  switch (protection)
+    {
+    case DUMP_MEMORY_ACCESS_NONE:
+      mem_prot = PROT_NONE;
+      mem_flags = MAP_SHARED;
+      break;
+    case DUMP_MEMORY_ACCESS_READ:
+      mem_prot = PROT_READ;
+      mem_flags = MAP_SHARED;
+      break;
+    case DUMP_MEMORY_ACCESS_READWRITE:
+      mem_prot = PROT_READ | PROT_WRITE;
+      mem_flags = MAP_PRIVATE;
+      break;
+    }
+
   if (base)
     mem_flags |= MAP_FIXED;
 
-- 
2.48.1
>From ae7fdb7348b25e35ea6778220105a536458bfdae Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Subject: [PATCH 3/4] Revert "Prefer static switch-case checking in pdumper"

This reverts commit 6e2e7265a04f63f482db7fbdfd8e2519d8bfe03e.
---
 src/pdumper.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/pdumper.c b/src/pdumper.c
index 45a44db0243..71d82629b56 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2392,6 +2392,8 @@ dump_fwd (struct dump_context *ctx, lispfwd fwd)
     case Lisp_Fwd_Kboard_Obj:
       offset = dump_fwd_kboard_obj (ctx, p);
       break;
+    default:
+      emacs_abort ();
     }
 
   return offset;
@@ -2523,6 +2525,8 @@ dump_symbol (struct dump_context *ctx,
     case SYMBOL_FORWARDED:
       dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.fwd);
       break;
+    default:
+      emacs_abort ();
     }
   dump_field_lv (ctx, &out, symbol, &symbol->u.s.function, WEIGHT_NORMAL);
   dump_field_lv (ctx, &out, symbol, &symbol->u.s.plist, WEIGHT_NORMAL);
@@ -3603,6 +3607,8 @@ dump_drain_cold_data (struct dump_context *ctx)
 	  dump_cold_native_subr (ctx, data);
 	  break;
 #endif
+        default:
+          emacs_abort ();
         }
     }
 
@@ -4067,6 +4073,8 @@ dump_do_fixup (struct dump_context *ctx,
         do_write = false;
         break;
       }
+    default:
+      emacs_abort ();
     }
   if (do_write)
     dump_write (ctx, &dump_value, sizeof (dump_value));
@@ -4525,6 +4533,8 @@ dump_anonymous_allocate_w32 (void *base,
       mem_type = MEM_COMMIT;
       mem_prot = PAGE_READWRITE;
       break;
+    default:
+      emacs_abort ();
     }
 
   ret = VirtualAlloc (base, size, mem_type, mem_prot);
@@ -4563,6 +4573,8 @@ dump_anonymous_allocate_posix (void *base,
     case DUMP_MEMORY_ACCESS_READWRITE:
       mem_prot = PROT_READ | PROT_WRITE;
       break;
+    default:
+      emacs_abort ();
     }
 
   int mem_flags = MAP_PRIVATE | MAP_ANONYMOUS;
@@ -4655,6 +4667,7 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
     case DUMP_MEMORY_ACCESS_READWRITE:
       protect = PAGE_WRITECOPY;	/* for Windows 9X */
       break;
+    default:
     case DUMP_MEMORY_ACCESS_NONE:
     case DUMP_MEMORY_ACCESS_READ:
       protect = PAGE_READONLY;
@@ -4682,6 +4695,8 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
     case DUMP_MEMORY_ACCESS_READWRITE:
       map_access = FILE_MAP_COPY;
       break;
+    default:
+      emacs_abort ();
     }
 
   ret = MapViewOfFileEx (section,
@@ -4724,6 +4739,8 @@ dump_map_file_posix (void *base, int fd, off_t offset, size_t size,
       mem_prot = PROT_READ | PROT_WRITE;
       mem_flags = MAP_PRIVATE;
       break;
+    default:
+      emacs_abort ();
     }
 
   if (base)
@@ -5590,6 +5607,8 @@ dump_do_emacs_relocation (const uintptr_t dump_base,
         memcpy (emacs_ptr_at (reloc.emacs_offset), &lv, sizeof (lv));
         break;
       }
+    default:
+      fatal ("unrecognied relocation type %d", (int) reloc.type);
     }
 }
 
-- 
2.48.1

>From 9aff2f5644f4933747d7af5412f2cffc8b2c98b2 Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Subject: [PATCH 4/4] Enable -Wswitch-enum in pdumper.c (bug#75964)

* src/Makefile.in (unfixed_Wswitch_obj): Remove 'pdumper.o'.
* src/pdumper.c (enum dump_reloc_type): Only include nativecomp cases
if HAVE_NATIVE_COMP.  Add additional cases to cover ranges.
(dump_reloc_dump_to_emacs_lv):
(dump_field_lv_or_rawptr):
(dump_fwd):
(dump_pre_dump_symbol):
(dump_symbol):
(dump_vectorlike):
(dump_drain_cold_data):
(read_ptr_raw_and_lv):
(decode_emacs_reloc):
(dump_do_fixup):
(dump_anonymous_allocate_w32):
(dump_anonymous_allocate_posix):
(dump_map_file_w32):
(dump_map_file_posix):
(dump_do_emacs_relocation): Expand 'default' labels.  Always
eassume (0) for 'default' labels.
(dump_object): Also use 'emacs_abort ()' rather than 'abort'.
(dump_do_dump_relocation): Also Handle case ranges explicitly.
---
 src/Makefile.in |  1 -
 src/pdumper.c   | 94 ++++++++++++++++++++++++++++++++-----------------
 2 files changed, 61 insertions(+), 34 deletions(-)

diff --git a/src/Makefile.in b/src/Makefile.in
index 7388284fef2..79a88af3584 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -546,7 +546,6 @@ unfixed_Wswitch_obj +=
 unfixed_Wswitch_obj += nsselect.o
 unfixed_Wswitch_obj += nsterm.o
 unfixed_Wswitch_obj += nsxwidget.o
-unfixed_Wswitch_obj += pdumper.o
 unfixed_Wswitch_obj += pgtkfns.o
 unfixed_Wswitch_obj += pgtkterm.o
 unfixed_Wswitch_obj += print.o
diff --git a/src/pdumper.c b/src/pdumper.c
index 71d82629b56..93119fd09c2 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -178,19 +178,35 @@ #define dump_offsetof(type, member)                             \
     /* dump_ptr = dump_ptr + dump_base  */
     RELOC_DUMP_TO_DUMP_PTR_RAW,
     /* dump_mpz = [rebuild bignum]  */
+#ifdef HAVE_NATIVE_COMP
     RELOC_NATIVE_COMP_UNIT,
     RELOC_NATIVE_SUBR,
+#endif
     RELOC_BIGNUM,
     /* dump_lv = make_lisp_ptr (dump_lv + dump_base,
 				type - RELOC_DUMP_TO_DUMP_LV)
        (Special case for symbols: make_lisp_symbol)
        Must be second-last.  */
     RELOC_DUMP_TO_DUMP_LV,
+    RELOC_DUMP_TO_DUMP_LV1,
+    RELOC_DUMP_TO_DUMP_LV2,
+    RELOC_DUMP_TO_DUMP_LV3,
+    RELOC_DUMP_TO_DUMP_LV4,
+    RELOC_DUMP_TO_DUMP_LV5,
+    RELOC_DUMP_TO_DUMP_LV6,
+    RELOC_DUMP_TO_DUMP_LV7,
     /* dump_lv = make_lisp_ptr (dump_lv + emacs_basis(),
 				type - RELOC_DUMP_TO_DUMP_LV)
        (Special case for symbols: make_lisp_symbol.)
        Must be last.  */
     RELOC_DUMP_TO_EMACS_LV = RELOC_DUMP_TO_DUMP_LV + 8,
+    RELOC_DUMP_TO_EMACS_LV1,
+    RELOC_DUMP_TO_EMACS_LV2,
+    RELOC_DUMP_TO_EMACS_LV3,
+    RELOC_DUMP_TO_EMACS_LV4,
+    RELOC_DUMP_TO_EMACS_LV5,
+    RELOC_DUMP_TO_EMACS_LV6,
+    RELOC_DUMP_TO_EMACS_LV7,
   };
 
 enum emacs_reloc_type
@@ -1445,8 +1461,11 @@ dump_reloc_dump_to_dump_lv (struct dump_context *ctx,
     case Lisp_Float:
       reloc_type = RELOC_DUMP_TO_DUMP_LV + type;
       break;
-    default:
+    case Lisp_Int0:
+    case Lisp_Int1:
       emacs_abort ();
+    case Lisp_Type_Unused0: eassume (0);
+    default: eassume (0);
     }
 
   dump_push (&ctx->dump_relocs[EARLY_RELOCS],
@@ -1494,8 +1513,12 @@ dump_reloc_dump_to_emacs_lv (struct dump_context *ctx,
     case Lisp_Float:
       reloc_type = RELOC_DUMP_TO_EMACS_LV + type;
       break;
-    default:
+    case Lisp_Symbol:
+    case Lisp_Int0:
+    case Lisp_Int1:
       emacs_abort ();
+    case Lisp_Type_Unused0: eassume (0);
+    default: eassume (0);
     }
 
   dump_push (&ctx->dump_relocs[EARLY_RELOCS],
@@ -1817,8 +1840,12 @@ dump_field_lv_or_rawptr (struct dump_context *ctx,
         case Lisp_Float:
           value = make_lisp_ptr (ptrval, *ptr_raw_type);
           break;
-        default:
-          emacs_abort ();
+	case Lisp_Int0:
+	case Lisp_Int1:
+	  emacs_abort ();
+
+	case Lisp_Type_Unused0: eassume (0);
+        default: eassume (0);
         }
     }
 
@@ -2392,8 +2419,7 @@ dump_fwd (struct dump_context *ctx, lispfwd fwd)
     case Lisp_Fwd_Kboard_Obj:
       offset = dump_fwd_kboard_obj (ctx, p);
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   return offset;
@@ -2458,8 +2484,10 @@ dump_pre_dump_symbol (struct dump_context *ctx, struct Lisp_Symbol *symbol)
       dump_remember_symbol_aux (ctx, symbol_lv,
 				dump_fwd (ctx, symbol->u.s.val.fwd));
       break;
-    default:
+    case SYMBOL_PLAINVAL:
+    case SYMBOL_VARALIAS:
       break;
+    default: eassume (0);
     }
   dump_clear_referrer (ctx);
 }
@@ -2525,8 +2553,7 @@ dump_symbol (struct dump_context *ctx,
     case SYMBOL_FORWARDED:
       dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.fwd);
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
   dump_field_lv (ctx, &out, symbol, &symbol->u.s.function, WEIGHT_NORMAL);
   dump_field_lv (ctx, &out, symbol, &symbol->u.s.plist, WEIGHT_NORMAL);
@@ -2556,8 +2583,10 @@ dump_symbol (struct dump_context *ctx,
 	  ? aux_offset
 	  : dump_fwd (ctx, symbol->u.s.val.fwd)));
       break;
-    default:
+    case SYMBOL_PLAINVAL:
+    case SYMBOL_VARALIAS:
       break;
+    default: eassume (0);
     }
   return offset;
 }
@@ -3144,10 +3173,11 @@ dump_vectorlike (struct dump_context *ctx,
     case PVEC_SQLITE:
     case PVEC_MODULE_FUNCTION:
     case PVEC_SYMBOL_WITH_POS:
-    case PVEC_FREE:
     case PVEC_TS_PARSER:
     case PVEC_TS_NODE:
       break;
+    case PVEC_FREE: eassume (0);
+    default: eassume (0);
     }
   int iptype = ptype;
   static char const fmt[] = "pseudovector type %d";
@@ -3249,9 +3279,9 @@ dump_object (struct dump_context *ctx, Lisp_Object object)
     case Lisp_Int0:
     case Lisp_Int1:
       eassert ("should not be dumping int: is self-representing" && 0);
-      abort ();
-    default:
       emacs_abort ();
+    case Lisp_Type_Unused0: eassume (0);
+    default: eassume (0);
     }
   dump_clear_referrer (ctx);
 
@@ -3607,8 +3637,7 @@ dump_drain_cold_data (struct dump_context *ctx)
 	  dump_cold_native_subr (ctx, data);
 	  break;
 #endif
-        default:
-          emacs_abort ();
+        default: eassume (0);
         }
     }
 
@@ -3635,8 +3664,11 @@ read_ptr_raw_and_lv (const void *mem,
         case Lisp_Float:
           *out_lv = make_lisp_ptr (*out_ptr, type);
           break;
-        default:
-          emacs_abort ();
+	case Lisp_Int0:
+	case Lisp_Int1:
+	case Lisp_Type_Unused0:
+	  eassume (0);
+	default: eassume (0);
         }
     }
 }
@@ -3888,8 +3920,7 @@ decode_emacs_reloc (struct dump_context *ctx, Lisp_Object lreloc)
           }
       }
       break;
-    default:
-      eassume (!"not reached");
+    default: eassume (0);
     }
 
   /* We should have consumed the whole relocation descriptor.  */
@@ -4073,8 +4104,7 @@ dump_do_fixup (struct dump_context *ctx,
         do_write = false;
         break;
       }
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
   if (do_write)
     dump_write (ctx, &dump_value, sizeof (dump_value));
@@ -4533,8 +4563,7 @@ dump_anonymous_allocate_w32 (void *base,
       mem_type = MEM_COMMIT;
       mem_prot = PAGE_READWRITE;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   ret = VirtualAlloc (base, size, mem_type, mem_prot);
@@ -4573,8 +4602,7 @@ dump_anonymous_allocate_posix (void *base,
     case DUMP_MEMORY_ACCESS_READWRITE:
       mem_prot = PROT_READ | PROT_WRITE;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   int mem_flags = MAP_PRIVATE | MAP_ANONYMOUS;
@@ -4667,11 +4695,11 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
     case DUMP_MEMORY_ACCESS_READWRITE:
       protect = PAGE_WRITECOPY;	/* for Windows 9X */
       break;
-    default:
     case DUMP_MEMORY_ACCESS_NONE:
     case DUMP_MEMORY_ACCESS_READ:
       protect = PAGE_READONLY;
       break;
+    default: eassume (0);
     }
 
   section = CreateFileMapping (file,
@@ -4695,8 +4723,7 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
     case DUMP_MEMORY_ACCESS_READWRITE:
       map_access = FILE_MAP_COPY;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   ret = MapViewOfFileEx (section,
@@ -4739,8 +4766,7 @@ dump_map_file_posix (void *base, int fd, off_t offset, size_t size,
       mem_prot = PROT_READ | PROT_WRITE;
       mem_flags = MAP_PRIVATE;
       break;
-    default:
-      emacs_abort ();
+    default: eassume (0);
     }
 
   if (base)
@@ -5541,13 +5567,16 @@ dump_do_dump_relocation (const uintptr_t dump_base,
         mpz_roinit_n (bignum->value, limbs, reload_info.nlimbs);
         break;
       }
-    default: /* Lisp_Object in the dump; precise type in reloc.type */
+    case RELOC_DUMP_TO_DUMP_LV ... RELOC_DUMP_TO_DUMP_LV + 7:
+    case RELOC_DUMP_TO_EMACS_LV ... RELOC_DUMP_TO_EMACS_LV + 7:
+      /* Lisp_Object in the dump; precise type in reloc.type */
       {
         Lisp_Object lv = dump_make_lv_from_reloc (dump_base, reloc);
         eassert (dump_reloc_size (reloc) == sizeof (lv));
         dump_write_lv_to_dump (dump_base, reloc_offset, lv);
         break;
       }
+    default: eassume (0);
     }
 }
 
@@ -5607,8 +5636,7 @@ dump_do_emacs_relocation (const uintptr_t dump_base,
         memcpy (emacs_ptr_at (reloc.emacs_offset), &lv, sizeof (lv));
         break;
       }
-    default:
-      fatal ("unrecognied relocation type %d", (int) reloc.type);
+    default: eassume (0);
     }
 }
 
-- 
2.48.1

> Robert