../gdtoa/g__fmt.c:175:27: warning: initializer-string for character array 
is too long, array size is 16 but initializer has size 17 (including the null 
terminating character); did you mean to use the 'nonstring' attribute? 
[-Wunterminated-string-initialization]

Since GCC 8 we could also have used the attribute nonstring, as the
warning references - but just expand the buffer to fit the
null terminator for simplicity, instead of conditionally trying to
use an attribute.

Signed-off-by: Martin Storsjö <[email protected]>
---
 mingw-w64-crt/gdtoa/g__fmt.c               | 2 +-
 mingw-w64-crt/testcases/t_snprintf_tmpl.h  | 2 +-
 mingw-w64-crt/testcases/t_snwprintf_tmpl.h | 2 +-
 mingw-w64-crt/testcases/t_swprintf_tmpl.h  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-crt/gdtoa/g__fmt.c b/mingw-w64-crt/gdtoa/g__fmt.c
index 98ef7be14..762589d18 100644
--- a/mingw-w64-crt/gdtoa/g__fmt.c
+++ b/mingw-w64-crt/gdtoa/g__fmt.c
@@ -172,7 +172,7 @@ __add_nanbits_D2A(char *b, size_t blen, ULong *bits, int nb)
        char *rv;
        int i, j;
        size_t L;
-       static char Hexdig[16] = "0123456789abcdef";
+       static char Hexdig[17] = "0123456789abcdef";
 
        while(!bits[--nb])
                if (!nb)
diff --git a/mingw-w64-crt/testcases/t_snprintf_tmpl.h 
b/mingw-w64-crt/testcases/t_snprintf_tmpl.h
index de7c5144a..5e755b910 100644
--- a/mingw-w64-crt/testcases/t_snprintf_tmpl.h
+++ b/mingw-w64-crt/testcases/t_snprintf_tmpl.h
@@ -3,7 +3,7 @@
 
 int main() {
   int i;
-  char buffer[10] = "XXXXXXXXXX";
+  char buffer[11] = "XXXXXXXXXX";
   int ret = snprintf(buffer, 3, "%s", "AAA");
   if (ret != 3 || memcmp(buffer, "AA\0XXXXXXX", 10) != 0) {
     fprintf(stderr, "ret: expected=3 got=%d\n", ret);
diff --git a/mingw-w64-crt/testcases/t_snwprintf_tmpl.h 
b/mingw-w64-crt/testcases/t_snwprintf_tmpl.h
index 6ce0b00b4..15aff9ddf 100644
--- a/mingw-w64-crt/testcases/t_snwprintf_tmpl.h
+++ b/mingw-w64-crt/testcases/t_snwprintf_tmpl.h
@@ -3,7 +3,7 @@
 
 int main() {
   int i;
-  wchar_t buffer[10] = L"XXXXXXXXXX";
+  wchar_t buffer[11] = L"XXXXXXXXXX";
   int ret = snwprintf(buffer, 3, L"%ls", L"AAA");
   if (ret != 3 || wmemcmp(buffer, L"AA\0XXXXXXX", 10) != 0) {
     fprintf(stderr, "ret: expected=3 got=%d\n", ret);
diff --git a/mingw-w64-crt/testcases/t_swprintf_tmpl.h 
b/mingw-w64-crt/testcases/t_swprintf_tmpl.h
index d1bc4bc04..e7c6fa19f 100644
--- a/mingw-w64-crt/testcases/t_swprintf_tmpl.h
+++ b/mingw-w64-crt/testcases/t_swprintf_tmpl.h
@@ -3,7 +3,7 @@
 
 int main() {
   int i;
-  wchar_t buffer[10] = L"XXXXXXXXXX";
+  wchar_t buffer[11] = L"XXXXXXXXXX";
   int ret = swprintf(buffer, 3, L"%ls", L"AAA");
   if (ret >= 0 || wmemcmp(buffer, L"AA\0XXXXXXX", 10) != 0) {
     fprintf(stderr, "ret: expected=<0 got=%d\n", ret);
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to