This patch fixes the remaining -Wunterminated-string-initialization warnings
from gcc 15.

../../gltests/test-gc-arctwo.c:30:24: warning: initializer-string for array of 
'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 
chars into 8 available)
../../gltests/test-gc-arctwo.c:31:30: warning: initializer-string for array of 
'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 
chars into 8 available)
../../gltests/test-gc-arctwo.c:32:37: warning: initializer-string for array of 
'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 
chars into 8 available)
../../gltests/test-sf-istream.c:29:18: warning: initializer-string for array of 
'char' truncates NUL terminator but destination lacks 'nonstring' attribute (8 
chars into 7 available)
../../gltests/test-sfl-istream.c:29:18: warning: initializer-string for array 
of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute 
(10 chars into 9 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:37:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (92 chars into 91 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:80:37: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (9 chars into 8 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:97:37: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (7 chars into 6 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:111:38: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (22 chars into 21 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:127:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (25 chars into 24 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:145:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (102 chars into 101 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:172:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (17 chars into 16 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:188:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (16 chars into 15 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:204:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (50 chars into 49 available)
../../gltests/unilbrk/test-u8-possible-linebreaks.c:224:37: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (9 chars into 8 available)
../../gltests/unilbrk/test-u8-width-linebreaks.c:37:7: warning: 
initializer-string for array of 'unsigned char' truncates NUL terminator but 
destination lacks 'nonstring' attribute (92 chars into 91 available)
../../gltests/unilbrk/test-ulc-possible-linebreaks.c:38:7: warning: 
initializer-string for array of 'char' truncates NUL terminator but destination 
lacks 'nonstring' attribute (37 chars into 36 available)
../../gltests/unilbrk/test-ulc-possible-linebreaks.c:55:35: warning: 
initializer-string for array of 'char' truncates NUL terminator but destination 
lacks 'nonstring' attribute (22 chars into 21 available)
../../gltests/unilbrk/test-ulc-width-linebreaks.c:38:7: warning: 
initializer-string for array of 'char' truncates NUL terminator but destination 
lacks 'nonstring' attribute (37 chars into 36 available)
../../gltests/uniwbrk/test-u8-wordbreaks.c:36:7: warning: initializer-string 
for array of 'unsigned char' truncates NUL terminator but destination lacks 
'nonstring' attribute (92 chars into 91 available)
../../gltests/uniwbrk/test-u8-wordbreaks.c:63:7: warning: initializer-string 
for array of 'unsigned char' truncates NUL terminator but destination lacks 
'nonstring' attribute (107 chars into 106 available)
../../gltests/uniwbrk/test-u8-wordbreaks.c:88:37: warning: initializer-string 
for array of 'unsigned char' truncates NUL terminator but destination lacks 
'nonstring' attribute (9 chars into 8 available)
../../gltests/uniwbrk/test-u8-wordbreaks.c:105:7: warning: initializer-string 
for array of 'unsigned char' truncates NUL terminator but destination lacks 
'nonstring' attribute (19 chars into 18 available)
../../gltests/uniwbrk/test-ulc-wordbreaks.c:42:7: warning: initializer-string 
for array of 'char' truncates NUL terminator but destination lacks 'nonstring' 
attribute (37 chars into 36 available)


2025-04-26  Bruno Haible  <br...@clisp.org>

        Silence gcc 15 -Wunterminated-string-initialization warnings.
        * tests/test-gc-arctwo.c (main): Mark arrays as _GL_ATTRIBUTE_NONSTRING.
        * tests/test-sf-istream.c (test_open_stream): Likewise.
        * tests/test-sfl-istream.c (test_open_stream): Likewise.
        * tests/unilbrk/test-u8-possible-linebreaks.c (test_function): Likewise.
        * tests/unilbrk/test-u8-width-linebreaks.c (test_function): Likewise.
        * tests/unilbrk/test-ulc-possible-linebreaks.c (test_function):
        Likewise.
        * tests/unilbrk/test-ulc-width-linebreaks.c (test_function): Likewise.
        * tests/uniwbrk/test-u8-wordbreaks.c (main): Likewise.
        * tests/uniwbrk/test-ulc-wordbreaks.c (main): Likewise.

diff --git a/tests/test-gc-arctwo.c b/tests/test-gc-arctwo.c
index 9167746370..6f6d79fb62 100644
--- a/tests/test-gc-arctwo.c
+++ b/tests/test-gc-arctwo.c
@@ -27,9 +27,12 @@ main (int argc, char *argv[])
 {
   gc_cipher_handle ctx;
   /* Test vectors from RFC 2268. */
-  static char key[8] = "\xff\xff\xff\xff\xff\xff\xff\xff";
-  static char plaintext[8] = "\xff\xff\xff\xff\xff\xff\xff\xff";
-  static const char ciphertext[8] = "\x27\x8b\x27\xe4\x2e\x2f\x0d\x49";
+  static char key[8] _GL_ATTRIBUTE_NONSTRING =
+    "\xff\xff\xff\xff\xff\xff\xff\xff";
+  static char plaintext[8] _GL_ATTRIBUTE_NONSTRING =
+    "\xff\xff\xff\xff\xff\xff\xff\xff";
+  static const char ciphertext[8] _GL_ATTRIBUTE_NONSTRING =
+    "\x27\x8b\x27\xe4\x2e\x2f\x0d\x49";
   char scratch[16];
   Gc_rc rc;
 
diff --git a/tests/test-sf-istream.c b/tests/test-sf-istream.c
index e3063c34d6..74c6203e48 100644
--- a/tests/test-sf-istream.c
+++ b/tests/test-sf-istream.c
@@ -66,7 +66,7 @@ test_open_stream (sf_istream_t *stream)
 int
 main ()
 {
-  char const contents[CONTENTS_LEN] = CONTENTS;
+  char const contents[CONTENTS_LEN] _GL_ATTRIBUTE_NONSTRING = CONTENTS;
 
   /* Test reading from a file.  */
   {
diff --git a/tests/test-sfl-istream.c b/tests/test-sfl-istream.c
index e0e9a02a9e..bd72952c55 100644
--- a/tests/test-sfl-istream.c
+++ b/tests/test-sfl-istream.c
@@ -90,7 +90,7 @@ test_open_stream (sfl_istream_t *stream)
 int
 main ()
 {
-  char const contents[CONTENTS_LEN] = CONTENTS;
+  char const contents[CONTENTS_LEN] _GL_ATTRIBUTE_NONSTRING = CONTENTS;
 
   /* Test reading from a file.  */
   {
diff --git a/tests/unilbrk/test-u8-possible-linebreaks.c 
b/tests/unilbrk/test-u8-possible-linebreaks.c
index d83c1948fa..88a0d30ce3 100644
--- a/tests/unilbrk/test-u8-possible-linebreaks.c
+++ b/tests/unilbrk/test-u8-possible-linebreaks.c
@@ -32,7 +32,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
   my_u8_possible_linebreaks (NULL, 0, "GB18030", NULL);
 
   {
-    static const uint8_t input[91] =
+    static const uint8_t input[91] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. ЗЎравствуйте! x=(-b±sqrt(b²-4ac))/(2a)  
日本語,äž­æ–‡,한Ꞁ" */
       "Gr\303\274\303\237 Gott. 
\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265!
 x=(-b\302\261sqrt(b\302\262-4ac))/(2a)  
\346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\355\225\234\352\270\200\n";
 
@@ -77,7 +77,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* CR LF handling.  */
   {
-    static const uint8_t input[8] = "a\nb\rc\r\nd";
+    static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING = "a\nb\rc\r\nd";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
 
@@ -94,7 +94,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
   /* Test that a break is possible after a zero-width space followed by some
      regular spaces (rule LB8 in Unicode TR#14 revision 26).  */
   {
-    static const uint8_t input[6] = "x\342\200\213 y";
+    static const uint8_t input[6] _GL_ATTRIBUTE_NONSTRING = "x\342\200\213 y";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
 
@@ -108,7 +108,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* Test line breaking in a string with HTML markup.  */
   {
-    static const uint8_t input[21] = "<P>Some sentence.</P>";
+    static const uint8_t input[21] _GL_ATTRIBUTE_NONSTRING = "<P>Some 
sentence.</P>";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
 
@@ -123,7 +123,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* Test line breaking of combining marks.  */
   {
-    static const uint8_t input[24] =
+    static const uint8_t input[24] _GL_ATTRIBUTE_NONSTRING =
       "a\314\200\314\201e\314\200 \314\201o \314\200 o\302\240\314\200\n"
       "\314\200";
     char *p = (char *) malloc (SIZEOF (input));
@@ -141,7 +141,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* Test line breaking of zero-width joiners (U+200D).  */
   {
-    static const uint8_t input[101] =
+    static const uint8_t input[101] _GL_ATTRIBUTE_NONSTRING =
       
"\346\234\211\347\204\241\347\252\256\345\244\232\345\200\213\347\264\240\346\225\270\343\200\202\n"
 /* "æœ‰ç„¡çª®å€šå€‹çŽ æ•žã€‚" */
       
"\346\234\211\342\200\215\347\204\241\342\200\215\347\252\256\345\244\232\345\200\213\347\264\240\342\200\215\346\225\270\343\200\202\n"
       "\344\275\240\342\200\224\344\270\215\n" /* "äœ â€”äž" */
@@ -168,7 +168,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* Test line breaking of regional indicators.  */
   {
-    static const uint8_t input[16] =
+    static const uint8_t input[16] _GL_ATTRIBUTE_NONSTRING =
       "\360\237\207\251\360\237\207\252\360\237\207\253\360\237\207\267";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
@@ -184,7 +184,7 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
   /* Test special behaviour of hyphen/break-after character after
      Hebrew letter.  */
   {
-    static const uint8_t input[15] = /* "ab-אב-αβ-ω" */
+    static const uint8_t input[15] _GL_ATTRIBUTE_NONSTRING = /* 
"ab-אב-αβ-ω" */
       "ab-\327\220\327\221-\316\261\316\262-\317\211";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
@@ -200,7 +200,8 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* Test special behaviour before East Asian opening parenthesis (LB30).  */
   {
-    static const uint8_t input[49] = /* 
"日䞭韓統合挢字拡匵G「ナニコヌド」" */
+    static const uint8_t input[49] _GL_ATTRIBUTE_NONSTRING =
+      /* "日䞭韓統合挢字拡匵G「ナニコヌド」" */
       
"\346\227\245\344\270\255\351\237\223\347\265\261\345\220\210\346\274\242"
       "\345\255\227\346\213\241\345\274\265G\343\200\214\343\203\246"
       "\343\203\213\343\202\263\343\203\274\343\203\211\343\200\215";
@@ -221,7 +222,8 @@ test_function (void (*my_u8_possible_linebreaks) (const 
uint8_t *, size_t, const
 
   /* Test special behaviour of potential future emoji (LB30b).  */
   {
-    static const uint8_t input[8] = "\360\237\277\274\360\237\217\277";
+    static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING =
+      "\360\237\277\274\360\237\217\277";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
 
diff --git a/tests/unilbrk/test-u8-width-linebreaks.c 
b/tests/unilbrk/test-u8-width-linebreaks.c
index e96bd8ff6c..a9c9378b06 100644
--- a/tests/unilbrk/test-u8-width-linebreaks.c
+++ b/tests/unilbrk/test-u8-width-linebreaks.c
@@ -32,7 +32,7 @@ test_function (int (*my_u8_width_linebreaks) (const uint8_t 
*, size_t, int, int,
   my_u8_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
 
   {
-    static const uint8_t input[91] =
+    static const uint8_t input[91] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. ЗЎравствуйте! x=(-b±sqrt(b²-4ac))/(2a)  
日本語,äž­æ–‡,한Ꞁ" */
       "Gr\303\274\303\237 Gott. 
\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265!
 x=(-b\302\261sqrt(b\302\262-4ac))/(2a)  
\346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\355\225\234\352\270\200\n";
 
diff --git a/tests/unilbrk/test-ulc-possible-linebreaks.c 
b/tests/unilbrk/test-ulc-possible-linebreaks.c
index e0d517aeb6..70c572cad6 100644
--- a/tests/unilbrk/test-ulc-possible-linebreaks.c
+++ b/tests/unilbrk/test-ulc-possible-linebreaks.c
@@ -33,7 +33,7 @@ test_function (void (*my_ulc_possible_linebreaks) (const char 
*, size_t, const c
 
 #if HAVE_ICONV
   {
-    static const char input[36] =
+    static const char input[36] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */
       "Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n";
     char *p = (char *) malloc (SIZEOF (input));
@@ -52,7 +52,8 @@ test_function (void (*my_ulc_possible_linebreaks) (const char 
*, size_t, const c
 
   /* Test line breaking in a string with HTML markup.  */
   {
-    static const char input[21] = "<P>Some sentence.</P>";
+    static const char input[21] _GL_ATTRIBUTE_NONSTRING =
+      "<P>Some sentence.</P>";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
 
diff --git a/tests/unilbrk/test-ulc-width-linebreaks.c 
b/tests/unilbrk/test-ulc-width-linebreaks.c
index bf654d6813..b9c74b23a4 100644
--- a/tests/unilbrk/test-ulc-width-linebreaks.c
+++ b/tests/unilbrk/test-ulc-width-linebreaks.c
@@ -33,7 +33,7 @@ test_function (int (*my_ulc_width_linebreaks) (const char *, 
size_t, int, int, i
 
 #if HAVE_ICONV
   {
-    static const char input[36] =
+    static const char input[36] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */
       "Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n";
     char *p = (char *) malloc (SIZEOF (input));
diff --git a/tests/uniwbrk/test-u8-wordbreaks.c 
b/tests/uniwbrk/test-u8-wordbreaks.c
index b5f489c238..b8d035a981 100644
--- a/tests/uniwbrk/test-u8-wordbreaks.c
+++ b/tests/uniwbrk/test-u8-wordbreaks.c
@@ -31,7 +31,7 @@ main ()
   u8_wordbreaks (NULL, 0, NULL);
 
   {
-    static const uint8_t input[91] =
+    static const uint8_t input[91] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. ЗЎравствуйте! x=(-b±sqrt(b²-4ac))/(2a)  
日本語,äž­æ–‡,한Ꞁ" */
       "Gr\303\274\303\237 Gott. 
\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265!
 x=(-b\302\261sqrt(b\302\262-4ac))/(2a)  
\346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\355\225\234\352\270\200\n";
     char *p = (char *) malloc (SIZEOF (input));
@@ -58,7 +58,7 @@ main ()
 
   {
     /* Same input string, decomposed.  */
-    static const uint8_t input[106] =
+    static const uint8_t input[106] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. ЗЎравствуйте! x=(-b±sqrt(b²-4ac))/(2a)  
日本語,äž­æ–‡,한Ꞁ" */
       "Gru\314\210\303\237 Gott. 
\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\270\314\206\321\202\320\265!
 x=(-b\302\261sqrt(b\302\262-4ac))/(2a)  
\346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\341\204\222\341\205\241\341\206\253\341\204\200\341\205\263\341\206\257\n";
     char *p = (char *) malloc (SIZEOF (input));
@@ -85,7 +85,7 @@ main ()
 
   /* CR LF handling.  */
   {
-    static const uint8_t input[8] = "a\nb\rc\r\nd";
+    static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING = "a\nb\rc\r\nd";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
 
@@ -101,7 +101,7 @@ main ()
 
   /* Test regional indicators.  */
   {
-    static const uint8_t input[18] =
+    static const uint8_t input[18] _GL_ATTRIBUTE_NONSTRING =
       ".\360\237\207\251\360\237\207\252\360\237\207\253\360\237\207\267.";
     char *p = (char *) malloc (SIZEOF (input));
     size_t i;
diff --git a/tests/uniwbrk/test-ulc-wordbreaks.c 
b/tests/uniwbrk/test-ulc-wordbreaks.c
index 88399174f3..0d95fc383e 100644
--- a/tests/uniwbrk/test-ulc-wordbreaks.c
+++ b/tests/uniwbrk/test-ulc-wordbreaks.c
@@ -37,7 +37,7 @@ main ()
 
 #if HAVE_ICONV
   {
-    static const char input[36] =
+    static const char input[36] _GL_ATTRIBUTE_NONSTRING =
       /* "GrÌß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */
       "Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n";
     char *p = (char *) malloc (SIZEOF (input));




Reply via email to