From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18303 invoked by alias); 14 Dec 2013 23:47:26 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 18280 invoked by uid 48); 14 Dec 2013 23:47:21 -0000 From: "mickey.veksler at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55217] False -Wstrict-overflow warning Date: Sat, 14 Dec 2013 23:47:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mickey.veksler at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg01261.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55217 Michael Veksler changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mickey.veksler at gmail do= t com --- Comment #1 from Michael Veksler --- (Strange that this hasn't been confirmed for over a year!) I have a similar issue with gcc-4.8 with a slightly different test-case.=20 So first I looked into your test case. To me it seems that gcc-4.7 warning = does look strange here, but with gcc-4.8 things look better: ---- gcc -c -O2 -Wstrict-overflow=3D2 beta.c -std=3Dc99 beta.c: In function =E2=80=98f=E2=80=99: beta.c:7:20: warning: assuming signed overflow does not occur when simplify= ing conditional to constant [-Wstrict-overflow] if (r) ^ beta.c:10:17: warning: assuming signed overflow does not occur when simplif= ying conditional to constant [-Wstrict-overflow] for (int j =3D 0; j < r; j++) --- The first warning for if(r) makes sense. However, the second warning does not make sense. Even after removing the 'i= f' the warning stays: --- void f(int n, int s) { int r =3D 1; for (int i =3D 1; i < n; i++) if (r) r++; for (int j =3D 0; j < r; j++) h(&s); } gamma.c:9:9: warning: assuming signed overflow does not occur when simplify= ing conditional to constant [-Wstrict-overflow] for (int j =3D 0; j < r; j++) --- It is as if gcc transforms the for loop to: int j=3D0; if (j >=3D r) goto done; // <--- does the warning come from here? loop: h(&s); j++ if (j < r) goto loop; done: I assume that then gcc notices that r>=3D1, unless it overflows, and hence j>=3Dr must be false for the first j, i.e., j=3D0. If this is what happens, then this is the wrong way to do it. If the same expression is duplicated then -Wstrict-overflow should be emitted only if it applies to both duplicates, or am I missing something? >>From gcc-bugs-return-437607-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Dec 15 00:07:50 2013 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 24956 invoked by alias); 15 Dec 2013 00:07:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 24936 invoked by uid 48); 15 Dec 2013 00:07:46 -0000 From: "mickey.veksler at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55217] False -Wstrict-overflow warning Date: Sun, 15 Dec 2013 00:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mickey.veksler at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg01262.txt.bz2 Content-length: 2295 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55217 --- Comment #2 from Michael Veksler --- A much more clear-cut, weird, and severe case: $ cat delta.c int bar(); void foo() { int stop=3D 0; for (int i=3D10 ; i>=3D0 && !stop; --i) { stop=3D bar(); } } $ gcc -c -O3 -Wstrict-overflow=3D3 delta.c -std=3Dc99 delta.c: In function =E2=80=98foo=E2=80=99: delta.c:5:22: warning: assuming signed overflow does not occur when changin= g X +- C1 cmp C2 to X cmp C1 +- C2 [-Wstrict-overflow] for (int i=3D10 ; i>=3D0 && !stop; --i) { ^ This make no sense at all and significantly lowers the usability of -Wstrict-overflow=3D3. Either VRP or constant-propagation must have realize= d that overflow is impossible, or does VRP come into play only after the warning is emitted? Or maybe VRP can't do it because such reasoning requires induction? Oh, and: $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=3Dfile:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=3Dc,c++,java,go,d,fortran,objc,obj-c++ --prefix=3D/usr --program-suffix=3D-4.8 --enable-shared --enable-linker-build-id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --with-gxx-include-dir=3D/usr/include/c++/4.8 --libdir=3D/usr/lib --enable-= nls --with-sysroot=3D/ --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=3Dgtk --enable-gtk-cairo --with-java-home=3D/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64= /jre --enable-java-home --with-jvm-root-dir=3D/usr/lib/jvm/java-1.5.0-gcj-4.8-am= d64 --with-jvm-jar-dir=3D/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=3Damd64 --with-ecj-jar=3D/usr/share/java/eclipse-ecj.= jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --with-tune=3Dgeneric --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linu= x-gnu --target=3Dx86_64-linux-gnu Thread model: posix gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) >>From gcc-bugs-return-437608-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Dec 15 01:59:00 2013 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 12281 invoked by alias); 15 Dec 2013 01:58:59 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 9847 invoked by uid 48); 15 Dec 2013 01:58:54 -0000 From: "jvdelisle at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/59419] [4.9 Regression] Failing OPEN with FILE='xxx' and IOSTAT creates the file 'xxx' after revision 196783 Date: Sun, 15 Dec 2013 01:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jvdelisle at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jvdelisle at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg01263.txt.bz2 Content-length: 1065 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59419 Jerry DeLisle changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |jvdelisle at gcc dot gnu.org --- Comment #5 from Jerry DeLisle --- There are 140 calls to generate_error in the library. I have begun an audit of these and see the "design" plan that was intended. I would like to stick to that design plan and not modify generate error. Most places are handled correctly. Generally speaking, after doing multiple groups of error checking these are checked by lines such as: if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK) This statement checks if all was OK before actually taking any actions. It is done this way for runtime efficiency. In short there are a few places where I need to clean up the code a little. I have started the patch, so will assign this bug to myself.