From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28951 invoked by alias); 12 Mar 2012 11:19:20 -0000 Received: (qmail 28943 invoked by uid 22791); 12 Mar 2012 11:19:19 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_NX X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Mar 2012 11:19:06 +0000 From: "rjones at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/52560] New: if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant' Date: Mon, 12 Mar 2012 11:19:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rjones at redhat 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-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 X-SW-Source: 2012-03/txt/msg00839.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52560 Bug #: 52560 Summary: if (r =3D=3D -1) causes 'assuming signed overflow does = not occur when simplifying conditional to constant' Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: rjones@redhat.com Here is the reproducer: wget 'http://oirase.annexia.org/strict-overflow-warning.i.xz' unxz strict-overflow-warning.i.xz gcc -std=3Dgnu99 -O2 -Wstrict-overflow -c strict-overflow-warning.i The warning is: inspect_fs_unix.c: In function =E2=80=98check_fstab=E2=80=99: inspect_fs_unix.c:1075:6: warning: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow] However the code doesn't look like anything should be simplified, or a warning: n_app_md_devices =3D map_app_md_devices (g, &app_map); if (n_app_md_devices =3D=3D -1) goto error; where map_app_md_devices is a function that returns an int: static int map_app_md_devices (guestfs_h *g, Hash_table **map); and n_app_md_devices is also an int. I've tried this on several versions of gcc: gcc (GCC) 4.7.0 20120308 (Red Hat 4.7.0-0.19) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. (for further build info, go to: http://koji.fedoraproject.org/koji/buildinfo?buildID=3D305760 and click 'build logs') Same thing with this gcc from Ubuntu 11.10: $ gcc --version gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. We think this first started happening in gcc 4.5.1.