From unknown Fri Sep 05 16:58:33 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11927: shred.c i686-specific warning from gcc-4.7 on fedora 17 Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 12 Jul 2012 21:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 11927 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 11927@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.134212877828431 (code B ref -1); Thu, 12 Jul 2012 21:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 Jul 2012 21:32:58 +0000 Received: from localhost ([127.0.0.1]:36785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SpR0M-0007OV-15 for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:32:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35994) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SpR0I-0007OO-Ju for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:32:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpQut-0000G9-HA for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:27:20 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:54102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQut-0000G5-E7 for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:27:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQus-0005Ax-Ed for bug-coreutils@gnu.org; Thu, 12 Jul 2012 17:27:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpQur-0000Fd-F7 for bug-coreutils@gnu.org; Thu, 12 Jul 2012 17:27:18 -0400 Received: from mx.meyering.net ([88.168.87.75]:54229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQur-0000FV-0A for bug-coreutils@gnu.org; Thu, 12 Jul 2012 17:27:17 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id C53DA60091 for ; Thu, 12 Jul 2012 23:27:15 +0200 (CEST) From: Jim Meyering Date: Thu, 12 Jul 2012 23:27:15 +0200 Message-ID: <87629svff0.fsf@rho.meyering.net> Lines: 62 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) [mostly for the record, and so I don't forget. I'm not ready to push this just yet. ] Building shred with fedora 17 and its stock gcc 4.7 on i686, I see this warning/error: CC shred.o shred.c: In function 'dopass': shred.c:501:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] shred.c:504:18: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] cc1: all warnings being treated as errors make[3]: *** [shred.o] Error 1 make[3]: Leaving directory `/f12/home/meyering/w/co/cu/src' make[2]: *** [all] Error 2 make[2]: Leaving directory `/f12/home/meyering/w/co/cu/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/f12/home/meyering/w/co/cu' make: *** [all] Error 2 I didn't really understand the cause but ended up writing the following patch to avoid the problem while making the code slightly more readable: diff --git a/src/shred.c b/src/shred.c index 7a28260..322bcf1 100644 --- a/src/shred.c +++ b/src/shred.c @@ -485,10 +485,11 @@ dopass (int fd, char const *qname, off_t *sizep, int type, offset += soff; + bool done = offset == size; + /* Time to print progress? */ - if (n - && ((offset == size && *previous_human_offset) - || thresh <= (now = time (NULL)))) + if (n && ((done && *previous_human_offset) + || thresh <= (now = time (NULL)))) { char offset_buf[LONGEST_HUMAN_READABLE + 1]; char size_buf[LONGEST_HUMAN_READABLE + 1]; @@ -498,8 +499,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type, = human_readable (offset, offset_buf, human_floor | human_progress_opts, 1, 1); - if (offset == size - || !STREQ (previous_human_offset, human_offset)) + if (done || !STREQ (previous_human_offset, human_offset)) { if (size < 0) error (0, 0, _("%s: pass %lu/%lu (%s)...%s"), @@ -516,7 +516,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type, = human_readable (size, size_buf, human_ceiling | human_progress_opts, 1, 1); - if (offset == size) + if (done) human_offset = human_size; error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"), qname, k, n, pass_string, human_offset, human_size, From unknown Fri Sep 05 16:58:33 2025 X-Loop: help-debbugs@gnu.org Subject: bug#11927: shred.c i686-specific warning from gcc-4.7 on fedora 17 Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 12 Jul 2012 23:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11927 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jim Meyering Cc: 11927@debbugs.gnu.org Received: via spool by 11927-submit@debbugs.gnu.org id=B11927.13421360796255 (code B ref 11927); Thu, 12 Jul 2012 23:35:01 +0000 Received: (at 11927) by debbugs.gnu.org; 12 Jul 2012 23:34:39 +0000 Received: from localhost ([127.0.0.1]:36930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SpSu7-0001cp-Et for submit@debbugs.gnu.org; Thu, 12 Jul 2012 19:34:39 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:44304) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SpSu4-0001ch-8Q for 11927@debbugs.gnu.org; Thu, 12 Jul 2012 19:34:38 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 2998439E8008; Thu, 12 Jul 2012 16:29:01 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0XwUamg89vsa; Thu, 12 Jul 2012 16:29:00 -0700 (PDT) Received: from [192.168.1.4] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 5C565A60001; Thu, 12 Jul 2012 16:29:00 -0700 (PDT) Message-ID: <4FFF5DBE.6000206@cs.ucla.edu> Date: Thu, 12 Jul 2012 16:29:02 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 References: <87629svff0.fsf@rho.meyering.net> In-Reply-To: <87629svff0.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 07/12/2012 02:27 PM, Jim Meyering wrote: > I didn't really understand the cause That one is one of my least favorite warnings because sometimes it warns about real bugs but often, as in your case, the warning is either bogus or so hard to figure out that it might as well be bogus. I see that you and I and others have been filing GCC bug reports in this area: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51309 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48267 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34515 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49234 In this particular case the shred.c rewrite seems harmless. From unknown Fri Sep 05 16:58:33 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.428 (Entity 5.428) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jim Meyering Subject: bug#11927: closed (Re: bug#11927: shred.c i686-specific warning from gcc-4.7 on fedora 17) Message-ID: References: <87hat9nz73.fsf@rho.meyering.net> <87629svff0.fsf@rho.meyering.net> X-Gnu-PR-Message: they-closed 11927 X-Gnu-PR-Package: coreutils Reply-To: 11927@debbugs.gnu.org Date: Sun, 15 Jul 2012 09:43:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1342345381-19134-1" This is a multi-part message in MIME format... ------------=_1342345381-19134-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #11927: shred.c i686-specific warning from gcc-4.7 on fedora 17 which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 11927@debbugs.gnu.org. --=20 11927: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D11927 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1342345381-19134-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 11927-done) by debbugs.gnu.org; 15 Jul 2012 09:42:09 +0000 Received: from localhost ([127.0.0.1]:41705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SqLL6-0004xA-Qf for submit@debbugs.gnu.org; Sun, 15 Jul 2012 05:42:09 -0400 Received: from mx.meyering.net ([88.168.87.75]:51500) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SqLL4-0004x1-2y for 11927-done@debbugs.gnu.org; Sun, 15 Jul 2012 05:42:07 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 146FE63A1F; Sun, 15 Jul 2012 11:36:16 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#11927: shred.c i686-specific warning from gcc-4.7 on fedora 17 In-Reply-To: <4FFF5DBE.6000206@cs.ucla.edu> (Paul Eggert's message of "Thu, 12 Jul 2012 16:29:02 -0700") References: <87629svff0.fsf@rho.meyering.net> <4FFF5DBE.6000206@cs.ucla.edu> Date: Sun, 15 Jul 2012 11:36:16 +0200 Message-ID: <87hat9nz73.fsf@rho.meyering.net> Lines: 75 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11927-done Cc: 11927-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Paul Eggert wrote: > On 07/12/2012 02:27 PM, Jim Meyering wrote: >> I didn't really understand the cause > > That one is one of my least favorite warnings > because sometimes it warns about real bugs but > often, as in your case, the warning is either > bogus or so hard to figure out that it might as > well be bogus. I see that you and I and others have > been filing GCC bug reports in this area: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51309 > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48267 > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904 > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34515 > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560 > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49234 > > In this particular case the shred.c rewrite seems harmless. Thanks for the review. I've just hit it again, so have pushed this: >From b255b9a68a0dcec113a193daa602bdcbda2658db Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 15 Jul 2012 11:31:18 +0200 Subject: [PATCH] build: shred.c: avoid i686-specific gcc -Wstrict-overflow warning * src/shred.c: Avoid gcc -Wstrict-overflow warning. Addresses http://bugs.gnu.org/11927 --- src/shred.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/shred.c b/src/shred.c index 7a28260..322bcf1 100644 --- a/src/shred.c +++ b/src/shred.c @@ -485,10 +485,11 @@ dopass (int fd, char const *qname, off_t *sizep, int type, offset += soff; + bool done = offset == size; + /* Time to print progress? */ - if (n - && ((offset == size && *previous_human_offset) - || thresh <= (now = time (NULL)))) + if (n && ((done && *previous_human_offset) + || thresh <= (now = time (NULL)))) { char offset_buf[LONGEST_HUMAN_READABLE + 1]; char size_buf[LONGEST_HUMAN_READABLE + 1]; @@ -498,8 +499,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type, = human_readable (offset, offset_buf, human_floor | human_progress_opts, 1, 1); - if (offset == size - || !STREQ (previous_human_offset, human_offset)) + if (done || !STREQ (previous_human_offset, human_offset)) { if (size < 0) error (0, 0, _("%s: pass %lu/%lu (%s)...%s"), @@ -516,7 +516,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type, = human_readable (size, size_buf, human_ceiling | human_progress_opts, 1, 1); - if (offset == size) + if (done) human_offset = human_size; error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"), qname, k, n, pass_string, human_offset, human_size, -- 1.7.11.2.194.g7bdb748 ------------=_1342345381-19134-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Jul 2012 21:32:58 +0000 Received: from localhost ([127.0.0.1]:36785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SpR0M-0007OV-15 for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:32:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35994) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SpR0I-0007OO-Ju for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:32:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpQut-0000G9-HA for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:27:20 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:54102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQut-0000G5-E7 for submit@debbugs.gnu.org; Thu, 12 Jul 2012 17:27:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQus-0005Ax-Ed for bug-coreutils@gnu.org; Thu, 12 Jul 2012 17:27:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpQur-0000Fd-F7 for bug-coreutils@gnu.org; Thu, 12 Jul 2012 17:27:18 -0400 Received: from mx.meyering.net ([88.168.87.75]:54229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpQur-0000FV-0A for bug-coreutils@gnu.org; Thu, 12 Jul 2012 17:27:17 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id C53DA60091 for ; Thu, 12 Jul 2012 23:27:15 +0200 (CEST) From: Jim Meyering To: bug-coreutils@gnu.org Subject: shred.c i686-specific warning from gcc-4.7 on fedora 17 Date: Thu, 12 Jul 2012 23:27:15 +0200 Message-ID: <87629svff0.fsf@rho.meyering.net> Lines: 62 MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) [mostly for the record, and so I don't forget. I'm not ready to push this just yet. ] Building shred with fedora 17 and its stock gcc 4.7 on i686, I see this warning/error: CC shred.o shred.c: In function 'dopass': shred.c:501:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] shred.c:504:18: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] cc1: all warnings being treated as errors make[3]: *** [shred.o] Error 1 make[3]: Leaving directory `/f12/home/meyering/w/co/cu/src' make[2]: *** [all] Error 2 make[2]: Leaving directory `/f12/home/meyering/w/co/cu/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/f12/home/meyering/w/co/cu' make: *** [all] Error 2 I didn't really understand the cause but ended up writing the following patch to avoid the problem while making the code slightly more readable: diff --git a/src/shred.c b/src/shred.c index 7a28260..322bcf1 100644 --- a/src/shred.c +++ b/src/shred.c @@ -485,10 +485,11 @@ dopass (int fd, char const *qname, off_t *sizep, int type, offset += soff; + bool done = offset == size; + /* Time to print progress? */ - if (n - && ((offset == size && *previous_human_offset) - || thresh <= (now = time (NULL)))) + if (n && ((done && *previous_human_offset) + || thresh <= (now = time (NULL)))) { char offset_buf[LONGEST_HUMAN_READABLE + 1]; char size_buf[LONGEST_HUMAN_READABLE + 1]; @@ -498,8 +499,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type, = human_readable (offset, offset_buf, human_floor | human_progress_opts, 1, 1); - if (offset == size - || !STREQ (previous_human_offset, human_offset)) + if (done || !STREQ (previous_human_offset, human_offset)) { if (size < 0) error (0, 0, _("%s: pass %lu/%lu (%s)...%s"), @@ -516,7 +516,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type, = human_readable (size, size_buf, human_ceiling | human_progress_opts, 1, 1); - if (offset == size) + if (done) human_offset = human_size; error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"), qname, k, n, pass_string, human_offset, human_size, ------------=_1342345381-19134-1--