public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fix build with GCC 7
@ 2018-04-17 20:20 Yaakov Selkowitz
  0 siblings, 0 replies; only message in thread
From: Yaakov Selkowitz @ 2018-04-17 20:20 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=67609efeb0bcb198463a952a6a214813794a9c2b

commit 67609efeb0bcb198463a952a6a214813794a9c2b
Author: Yaakov Selkowitz <yselkowi@redhat.com>
Date:   Mon Apr 16 22:46:11 2018 -0500

    Cygwin: fix build with GCC 7
    
    GCC 7 is able to see straight through this trick, so use a more formal
    method to avoid the warning.
    
    Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>

Diff:
---
 winsup/cygwin/random.cc | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc
index 802c33b..163fc04 100644
--- a/winsup/cygwin/random.cc
+++ b/winsup/cygwin/random.cc
@@ -279,14 +279,6 @@ srandom(unsigned x)
 		(void)random();
 }
 
-/* Avoid a compiler warning when we really want to get at the junk in
-   an uninitialized variable. */
-static unsigned long
-dummy (unsigned volatile long *x)
-{
-  return *x;
-}
-
 /*
  * srandomdev:
  *
@@ -313,7 +305,11 @@ srandomdev()
 		unsigned long junk;
 
 		gettimeofday(&tv, NULL);
-		srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ dummy(&junk));
+		/* Avoid a compiler warning when we really want to get at the
+		   junk in an uninitialized variable. */
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+		srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
+#pragma GCC diagnostic pop
 		return;
 	}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-17 20:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17 20:20 [newlib-cygwin] Cygwin: fix build with GCC 7 Yaakov Selkowitz

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).