public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55217] New: False -Wstrict-overflow warning
@ 2012-11-05 20:21 mattiase at acm dot org
  2013-12-14 23:47 ` [Bug c/55217] " mickey.veksler at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mattiase at acm dot org @ 2012-11-05 20:21 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55217
           Summary: False -Wstrict-overflow warning
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mattiase@acm.org


This code yields a false -Wstrict-overflow warning in gcc 4.7.2:

void h(int *s);
void f(int n, int s)
{
        int r = 1;
        for (int i = 1; i < n; i++)
                if (r)
                        r++;
        if (r * s >= s + 3)       // warning here
                for (int j = 0; j < r; j++)
                        h(&s);
}

beta.c:8:12: warning: assuming signed overflow does not occur when assuming
that (X + c) < X is always false [-Wstrict-overflow]

The condition is not on the form X+c<X, and can legitimately go either way.

Here is a variant with s hard-wired to 0. The call to g() seems necessary:

void g(void);
void h(int *s);
void f(int n)
{
        int s = 0;
        int r = 1;
        g();
        for (int i = 1; i < n; i++)
                if (r)
                        r++;
        if (r * s >= s + 3)      // warning here
                for (int j = 0; j < r; j++)
                        h(&s);
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-01 12:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 20:21 [Bug c/55217] New: False -Wstrict-overflow warning mattiase at acm dot org
2013-12-14 23:47 ` [Bug c/55217] " mickey.veksler at gmail dot com
2014-10-03 22:18 ` [Bug middle-end/55217] " mickey.veksler at gmail dot com
2021-12-13  3:06 ` pinskia at gcc dot gnu.org
2022-02-01 12:53 ` marxin at gcc dot gnu.org

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).