#1128548 hexcurse: FTBFS with glibc 2.43 due to ISO C23 const return types

Package:
src:hexcurse
Source:
src:hexcurse
Submitter:
Aurelien Jarno
Date:
2026-10-14 21:37:02 UTC
Severity:
normal
Tags:
#1128548#5
Date:
2026-02-20 22:57:56 UTC
From:
To:
Dear maintainer(s),

hexcurse fails to build from source with glibc 2.43, currently in
experimental. From the build log:

| gcc -DHAVE_CONFIG_H -I. -I..  -I../include -Wall -Werror -Wextra -Wdate-time -D_FORTIFY_SOURCE=2  -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/hexcurse-1.60.0=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -c -o color.o color.c
| getopt.c: In function ‘_getopt_internal’:
| getopt.c:361:18: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
|   361 |     char *temp = my_index (optstring, c);
|       |                  ^~~~~~~~
| cc1: all warnings being treated as errors
| make[3]: *** [Makefile:378: getopt.o] Error 1
| make[3]: *** Waiting for unfinished jobs....
| make[3]: Leaving directory '/build/reproducible-path/hexcurse-1.60.0/src'
| make[2]: *** [Makefile:370: all-recursive] Error 1
| make[2]: Leaving directory '/build/reproducible-path/hexcurse-1.60.0'
| make[1]: *** [Makefile:311: all] Error 2
| make[1]: Leaving directory '/build/reproducible-path/hexcurse-1.60.0'
| dh_auto_build: error: make -j128 returned exit code 2
| make: *** [debian/rules:6: binary] Error 25
| dpkg-buildpackage: error: debian/rules binary subprocess failed with exit status 2

The full build log is available here [1].

The issue is due to ISO C23 declaration of bsearch, memchr, strchr,
strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr,
which now returns a pointer to a const-qualified type when the input
argument is a pointer to a const-qualified type [2].

I would like to thanks Emanuele Rocca for doing the archive rebuild on
a fast arm64 server.

Regards
Aurelien

[1] https://people.debian.org/~ema/glibc-2.43-rebuilds/output-1/hexcurse_arm64.build
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=e271fb2e4d76903c77a302aaec1ca22ce31027d0;hb=f762ccf84f122d1354f103a151cba8bde797d521#l19

#1128548#12
Date:
2026-08-10 12:44:53 UTC
From:
To:
control: severity 1127629 serious
control: severity 1128547 serious
control: severity 1128734 serious
control: severity 1128740 serious
control: severity 1128528 serious
control: severity 1128532 serious
control: severity 1128534 serious
control: severity 1128541 serious
control: severity 1128544 serious
control: severity 1128545 serious
control: severity 1128548 serious
control: severity 1128549 serious
control: severity 1128551 serious
control: severity 1128615 serious
control: severity 1128678 serious
control: severity 1128680 serious
control: severity 1128681 serious
control: severity 1128697 serious
control: severity 1128736 serious
control: severity 1128737 serious
control: severity 1128738 serious
control: severity 1128741 serious
control: severity 1128742 serious
control: severity 1128743 serious
control: severity 1128750 serious
control: severity 1128757 serious
control: severity 1128761 serious
control: severity 1128763 serious
control: severity 1128764 serious
control: severity 1128875 serious
control: severity 1128952 serious
control: severity 1128542 serious
control: severity 1128679 serious
control: severity 1128682 serious
control: severity 1128744 serious
control: severity 1128748 serious
control: severity 1128867 serious

Hi,

With the upload of glibc 2.43 to unstable, the packages now FTBFS in
unstable, hence upgrading the severity to serious.

Note that as a quick workaround, it is possible to roll back to C/C++17
standard using -std=c17, -std=gnu17, std=c++17 or std=gnu++17. This was
the default up to GCC 14, and GCC 15 changed it to C/C23.

Regards
Aurelien

#1128548#17
Date:
2026-09-18 01:08:24 UTC
From:
To:
In C23 mode, glibc 2.43 strchr preserves the const qualification of
its input. The bundled option parser assigns the result for the
const optstring to a mutable pointer, which fails with
-Werror=discarded-qualifiers.

Make the local pointer const: it is only used to inspect the option
and its argument markers. Keep the compiler standard and warning
checks unchanged.

Closes: #1128548
---
 debian/patches/glibc-2.43-const.patch | 21 +++++++++++++++++++++
 debian/patches/series                 |  1 +
 2 files changed, 22 insertions(+)
 create mode 100644 debian/patches/glibc-2.43-const.patch

diff --git a/debian/patches/glibc-2.43-const.patch b/debian/patches/glibc-2.43-const.patch
new file mode 100644
index 0000000..f6e848e
--- /dev/null
+++ b/debian/patches/glibc-2.43-const.patch
@@ -0,0 +1,21 @@
+Description: Preserve const qualification when scanning the option string
+ In C23 mode, glibc 2.43 strchr preserves the const qualification of its
+ input. optstring is const char *, and temp only reads the matching
+ option and its argument markers. Declare temp const to avoid discarding
+ the qualifier and failing the build with -Werror=discarded-qualifiers.
+Author: Troy Mitchell <me@troy-y.org>
+Bug-Debian: https://bugs.debian.org/1128548
+Forwarded: no
+Last-Update: 2026-09-17
+
+--- a/src/getopt.c
++++ b/src/getopt.c
+@@ -358,7 +358,7 @@
+
+   {
+     char c = *nextchar++;
+-    char *temp = my_index (optstring, c);
++    const char *temp = my_index (optstring, c);
+
+     /* Increment `optind' when we start to process its last character.  */
+     if (*nextchar == '\0')
diff --git a/debian/patches/series b/debian/patches/series
index 25ce50e..95308d8 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ fix_ftbfs.patch
 gcc-10.patch
 0001-Fix-string-format-errors-with-recent-ncurses.patch
 gcc-15.patch
+glibc-2.43-const.patch

#1128548#22
Date:
2026-10-14 21:35:54 UTC
From:
To:
Hi,

The attached patch fixes the build. In _getopt_internal() the result of
my_index() (#define'd to strchr) on the const optstring is only ever read,
so the local can simply be declared const char *.

We are carrying it in Ubuntu as hexcurse 1.60.0-2ubuntu1.

Cheers,
Sebastien