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] Disable -Wrestrict for two nptl/tst-attr3.c tests.
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <20181022130221.D43074399457D@oldenburg.str.redhat.com> (raw)

From: Joseph Myers <joseph@codesourcery.com>

nptl/tst-attr3 fails to build with GCC mainline because of
(deliberate) aliasing between the second (attributes) and fourth
(argument to thread start routine) arguments to pthread_create.

Although both those arguments are restrict-qualified in POSIX,
pthread_create does not actually dereference its fourth argument; it's
an opaque pointer passed to the thread start routine.  Thus, the
aliasing is actually valid in this case, and it's deliberate in the
test.  So this patch makes the test disable -Wrestrict for the two
pthread_create calls in question.  (-Wrestrict was added in GCC 7,
hence the __GNUC_PREREQ conditions, but the particular warning in
question is new in GCC 8.)

Tested compilation with build-many-glibcs.py for aarch64-linux-gnu.

	* nptl/tst-attr3.c: Include <libc-diag.h>.
	(do_test) [__GNUC_PREREQ (7, 0)]: Ignore -Wrestrict for two tests.

(cherry picked from commit 40c4162df6766fb1e8ede875ca8df25d8075d3a5)

2017-12-18  Joseph Myers  <joseph@codesourcery.com>

	* nptl/tst-attr3.c: Include <libc-diag.h>.
	(do_test) [__GNUC_PREREQ (7, 0)]: Ignore -Wrestrict for two tests.

diff --git a/nptl/tst-attr3.c b/nptl/tst-attr3.c
index bc23386daf..420a7dba8b 100644
--- a/nptl/tst-attr3.c
+++ b/nptl/tst-attr3.c
@@ -26,6 +26,7 @@
 #include <unistd.h>
 
 #include <stackinfo.h>
+#include <libc-diag.h>
 
 static void *
 tf (void *arg)
@@ -362,7 +363,16 @@ do_test (void)
       result = 1;
     }
 
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (7, 0)
+  /* GCC 8 warns about aliasing of the restrict-qualified arguments
+     passed &a.  Since pthread_create does not dereference its fourth
+     argument, this aliasing, which is deliberate in this test, cannot
+     in fact cause problems.  */
+  DIAG_IGNORE_NEEDS_COMMENT (8, "-Wrestrict");
+#endif
   err = pthread_create (&th, &a, tf, &a);
+  DIAG_POP_NEEDS_COMMENT;
   if (err)
     {
       error (0, err, "pthread_create #2 failed");
@@ -388,7 +398,16 @@ do_test (void)
       result = 1;
     }
 
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (7, 0)
+  /* GCC 8 warns about aliasing of the restrict-qualified arguments
+     passed &a.  Since pthread_create does not dereference its fourth
+     argument, this aliasing, which is deliberate in this test, cannot
+     in fact cause problems.  */
+  DIAG_IGNORE_NEEDS_COMMENT (8, "-Wrestrict");
+#endif
   err = pthread_create (&th, &a, tf, &a);
+  DIAG_POP_NEEDS_COMMENT;
   if (err)
     {
       error (0, err, "pthread_create #3 failed");

                 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=20181022130221.D43074399457D@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).