1 From 50c02d93990e94bc6bacc1ce71e7895b40316b5a Mon Sep 17 00:00:00 2001
2 From: Linus Torvalds <torvalds@linux-foundation.org>
3 Date: Sun, 20 Apr 2025 15:30:53 -0700
4 Subject: gcc-15: disable '-Wunterminated-string-initialization' entirely for now
6 commit 9d7a0577c9db35c4cc52db90bc415ea248446472 upstream.
8 From: Linus Torvalds <torvalds@linux-foundation.org>
10 I had left the warning around but as a non-fatal error to get my gcc-15
11 builds going, but fixed up some of the most annoying warning cases so
12 that it wouldn't be *too* verbose.
14 Because I like the _concept_ of the warning, even if I detested the
15 implementation to shut it up.
17 It turns out the implementation to shut it up is even more broken than I
18 thought, and my "shut up most of the warnings" patch just caused fatal
19 errors on gcc-14 instead.
21 I had tested with clang, but when I upgrade my development environment,
22 I try to do it on all machines because I hate having different systems
23 to maintain, and hadn't realized that gcc-14 now had issues.
25 The ACPI case is literally why I wanted to have a *type* that doesn't
26 trigger the warning (see commit d5d45a7f2619: "gcc-15: make
27 'unterminated string initialization' just a warning"), instead of
28 marking individual places as "__nonstring".
30 But gcc-14 doesn't like that __nonstring location that shut gcc-15 up,
31 because it's on an array of char arrays, not on one single array:
33 drivers/acpi/tables.c:399:1: error: 'nonstring' attribute ignored on objects of type 'const char[][4]' [-Werror=attributes]
34 399 | static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst __nonstring = {
37 and my attempts to nest it properly with a type had failed, because of
38 how gcc doesn't like marking the types as having attributes, only
41 There may be some trick to it, but I was already annoyed by the bad
42 attribute design, now I'm just entirely fed up with it.
44 I wish gcc had a proper way to say "this type is a *byte* array, not a
47 The obvious thing would be to distinguish between "char []" and an
48 explicitly signed "unsigned char []" (as opposed to an implicitly
49 unsigned char, which is typically an architecture-specific default, but
50 for the kernel is universal thanks to '-funsigned-char').
52 But any "we can typedef a 8-bit type to not become a string just because
53 it's an array" model would be fine.
55 But "__attribute__((nonstring))" is sadly not that sane model.
57 Reported-by: Chris Clayton <chris2553@googlemail.com>
58 Fixes: 4b4bd8c50f48 ("gcc-15: acpi: sprinkle random '__nonstring' crumbles around")
59 Fixes: d5d45a7f2619 ("gcc-15: make 'unterminated string initialization' just a warning")
60 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
61 [nathan: drivers/acpi diff dropped due to lack of 4b4bd8c50f48 in stable]
62 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
63 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
66 1 file changed, 2 insertions(+), 2 deletions(-)
70 @@ -1001,8 +1001,8 @@ KBUILD_CFLAGS += $(call cc-option, -fstr
71 KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
72 KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
74 -#Currently, disable -Wunterminated-string-initialization as an error
75 -KBUILD_CFLAGS += $(call cc-option, -Wno-error=unterminated-string-initialization)
76 +#Currently, disable -Wunterminated-string-initialization as broken
77 +KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
79 # disable invalid "can't wrap" optimizations for signed / pointers
80 KBUILD_CFLAGS += -fno-strict-overflow