diff mbox series

[libfortran,committed] Suppress -Wstringop-overflow warning

Message ID c3b9d7b6-bcf7-ab7f-3b04-0217fbcd1e2d@netcologne.de
State New
Headers show
Series [libfortran,committed] Suppress -Wstringop-overflow warning | expand

Commit Message

Thomas Koenig June 13, 2020, 8:08 a.m. UTC
Hi,

I just committed as obvious the patch below.

Disable -Wstringop-overflow warning after checking code path of caller.

The warning that is disabled, only on this single line, has been
inspected and found to be not applicable; it is known that the size
of the buffer is safe.

libgfortran/ChangeLog:

2020-06-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/95313
	* io/write.c (ztoa_big): Disable -Wstringop-overflow for one
	line.
diff mbox series

Patch

diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 9f02683a25c..346615ed597 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1178,7 +1178,15 @@  ztoa_big (const char *s, char *buffer, int len, GFC_UINTEGER_LARGEST *n)
 	}
     }
 
+  /* write_z, which calls ztoa_big, is called from transfer.c,
+     formatted_transfer_scalar_write.  There it is passed the kind as
+     argument, which means a maximum of 16.  The buffer is large
+     enough, but the compiler does not know that, so shut up the
+     warning here.  */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
   *q = '\0';
+#pragma GCC diagnostic pop
 
   if (*n == 0)
     return "0";