public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mattiase at acm dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55217] New: False -Wstrict-overflow warning Date: Mon, 05 Nov 2012 20:21:00 -0000 [thread overview] Message-ID: <bug-55217-4@http.gcc.gnu.org/bugzilla/> (raw) 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); }
next reply other threads:[~2012-11-05 20:21 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-05 20:21 mattiase at acm dot org [this message] 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
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-55217-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: linkBe 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).