public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rjones at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-52560-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560

             Bug #: 52560
           Summary: if (r == -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=gnu99 -O2 -Wstrict-overflow -c strict-overflow-warning.i

The warning is:

  inspect_fs_unix.c: In function ‘check_fstab’:
  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 = map_app_md_devices (g, &app_map);
  if (n_app_md_devices == -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=305760
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.


             reply	other threads:[~2012-03-12 11:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12 11:19 rjones at redhat dot com [this message]
2012-03-12 12:30 ` [Bug c/52560] " jim at meyering dot net
2012-03-12 13:23 ` [Bug tree-optimization/52560] " rguenth at gcc dot gnu.org
2012-03-12 16:31 ` rjones at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-52560-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).