public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: fweimer@redhat.com (Florian Weimer)
To: libc-stable@sourceware.org
Subject: [2.26 COMMITTED] Fix string/bug-strncat1.c build with GCC 8.
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <20181022130220.044184399457D@oldenburg.str.redhat.com> (raw)

From: Joseph Myers <joseph@codesourcery.com>

GCC 8 warns about strncat calls with truncated output.
string/bug-strncat1.c tests such a call; this patch disables the
warning for it.

Tested (compilation) with GCC 8 for x86_64-linux-gnu with
build-many-glibcs.py (in conjunction with Martin's patch to allow
glibc to build).

	* string/bug-strncat1.c: Include <libc-diag.h>.
	(main): Disable -Wstringop-truncation for strncat call for GCC 8.

(cherry picked from commit ec72135e5f1d061cb5cf7cd1b855fd6290be10d9)

2017-11-14  Joseph Myers  <joseph@codesourcery.com>

	* string/bug-strncat1.c: Include <libc-diag.h>.
	(main): Disable -Wstringop-truncation for strncat call for GCC 8.

diff --git a/string/bug-strncat1.c b/string/bug-strncat1.c
index f1b5c37c5c..b22beba4d3 100644
--- a/string/bug-strncat1.c
+++ b/string/bug-strncat1.c
@@ -4,13 +4,21 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libc-diag.h>
 
 char d[3] = "\0\1\2";
 
 int
 main (void)
 {
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (8, 0)
+  /* GCC 8 warns about strncat truncating output; this is deliberately
+     tested here.  */
+  DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-truncation");
+#endif
   strncat (d, "\5\6", 1);
+  DIAG_POP_NEEDS_COMMENT;
   if (d[0] != '\5')
     {
       puts ("d[0] != '\\5'");

                 reply	other threads:[~2018-10-22 13:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022130220.044184399457D@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-stable@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).