From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11473 invoked by alias); 17 Apr 2018 20:20:11 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 11430 invoked by uid 9642); 17 Apr 2018 20:20:11 -0000 Date: Tue, 17 Apr 2018 20:20:00 -0000 Message-ID: <20180417202011.11427.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Yaakov Selkowitz To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: fix build with GCC 7 X-Act-Checkin: newlib-cygwin X-Git-Author: Yaakov Selkowitz X-Git-Refname: refs/heads/master X-Git-Oldrev: cd31fbb2aea25f94d7ecedc9db16dfc87ab0c316 X-Git-Newrev: 67609efeb0bcb198463a952a6a214813794a9c2b X-SW-Source: 2018-q2/txt/msg00006.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=67609efeb0bcb198463a952a6a214813794a9c2b commit 67609efeb0bcb198463a952a6a214813794a9c2b Author: Yaakov Selkowitz 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 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; }