GNU bug report logs - #77835
[PATCH] Pacify GCC 15 -Wunterminated-string-initialization warnings

Previous Next

Package: emacs;

Reported by: Collin Funk <collin.funk1 <at> gmail.com>

Date: Wed, 16 Apr 2025 05:25:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#77835: closed ([PATCH] Pacify GCC 15 -Wunterminated-string-initialization
 warnings)
Date: Sun, 20 Apr 2025 05:42:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 19 Apr 2025 22:41:33 -0700
with message-id <dd968342-ab06-4659-95ed-c1b27e6cde57 <at> cs.ucla.edu>
and subject line Re: bug#77835: [PATCH] Pacify GCC 15 -Wunterminated-string-initialization warnings
has caused the debbugs.gnu.org bug report #77835,
regarding [PATCH] Pacify GCC 15 -Wunterminated-string-initialization warnings
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
77835: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77835
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Collin Funk <collin.funk1 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Pacify GCC 15 -Wunterminated-string-initialization warnings
Date: Tue, 15 Apr 2025 22:24:16 -0700
[Message part 3 (text/plain, inline)]
GCC 15.0 enables -Wunterminated-string-initialization when using
'-Wall -Wextra', which gets used when I run './configure'. This patch
silences the warnings:

fns.c: In function ‘hexbuf_digest’:
fns.c:6019:40: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (17 chars into 16 available) [-Wunterminated-string-initialization]
 6019 |       static char const hexdigit[16] = "0123456789abcdef";
      |                                        ^~~~~~~~~~~~~~~~~~

Collin

[0001-Pacify-GCC-15-Wunterminated-string-initialization-wa.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>, Collin Funk <collin.funk1 <at> gmail.com>
Cc: 77835-done <at> debbugs.gnu.org
Subject: Re: bug#77835: [PATCH] Pacify GCC 15
 -Wunterminated-string-initialization warnings
Date: Sat, 19 Apr 2025 22:41:33 -0700
[Message part 6 (text/plain, inline)]
On 2025-04-16 02:40, Eli Zaretskii wrote:
> -      static char const hexdigit[16] = "0123456789abcdef";
> +      static char const hexdigit[17] = "0123456789abcdef";

Although that would pacify GCC, it would make the code more confusing 
because it doesn't clearly indicate to the human reader that hexdigit is 
unusual because it is used only as a 16-element array, not as a 
null-terminated string.

I ran into this problem independently and installed the obvious patch 
(attached). I didn't recall your email suggesting this other solution 
until just now. If you prefer the more-confusing solution please feel to 
install it, but at least please add comments explaining what's going on. 
Thanks.

Closing the bug report as the bug is fixed now, one way or another.
[0001-Pacify-GCC-15-Wunterminated-string-initialization.patch (text/x-patch, attachment)]

This bug report was last modified 32 days ago.

Previous Next


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