Index | Thread | Search

From:
Han Boetes <han@boetes.org>
Subject:
dired.c: error: type of helpmap does not match original declaration [-Werror=lto-type-mismatch]
To:
tech@openbsd.org
Date:
Mon, 18 Aug 2025 07:33:37 +0200

Download raw body.

Thread
Adding -flto to the compiler flags reveals a bug with the declaration of 
helpmap:


dired.c:63:24: warning: type of ‘helpmap’ does not match original 
declaration [-Wlto-type-mismatch]
    63 | extern struct keymap_s helpmap, cXmap, metamap;
       |                        ^
keymap.c:34:20: note: ‘helpmap’ was previously declared here
    34 | struct KEYMAPE (2) helpmap = {
       |                    ^
dired.c:63:33: warning: type of ‘cXmap’ does not match original 
declaration [-Wlto-type-mismatch]
    63 | extern struct keymap_s helpmap, cXmap, metamap;
       |                                 ^
keymap.c:194:20: note: ‘cXmap’ was previously declared here
   194 | struct KEYMAPE (6) cXmap = {
       |                    ^
dired.c:63:40: warning: type of ‘metamap’ does not match original 
declaration [-Wlto-type-mismatch]
    63 | extern struct keymap_s helpmap, cXmap, metamap;
       |                                        ^
keymap.c:319:20: note: ‘metamap’ was previously declared here
   319 | struct KEYMAPE (8) metamap = {
       |                    ^
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information


This patch should remedy the problem(original author unknown)

--- mg-20240709/dired.c
+++ mg-20240709/dired.c
@@ -60,7 +60,9 @@
  static void     redelete(struct buffer *);
  static char      *findfname(struct line *, char *);

-extern struct keymap_s helpmap, cXmap, metamap;
+extern struct KEYMAPE (2) helpmap;
+extern struct KEYMAPE (6) cXmap;
+extern struct KEYMAPE (8) metamap;

  const char DDELCHAR = 'D';

For reference:

- https://github.com/hboetes/mg/issues/36

- https://bugs.gentoo.org/940566