public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/58101] Wrong out-of-bounds warning under -Os
Date: Thu, 23 Dec 2021 06:36:57 +0000	[thread overview]
Message-ID: <bug-58101-4-Kh8nVo33Tp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58101-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58101

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Further reduced:
int a [1];

void foo (int n)
{
   if (n <= 1) return;
   int i = 1;
   a [i] = a [i - 1];
}

This is one of these false positives warning where we should maybe not warn but
instead just change the code to be a trap.

Note in the original testcase, GCC is able to remove the loop and just change
it to one statement. That is part of the reason for the warning even.

clang does not warn about the above because they only warn for the literal a[1]
case.

      parent reply	other threads:[~2021-12-23  6:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 18:31 [Bug c/58101] New: " llozano at google dot com
2013-08-07 22:54 ` [Bug middle-end/58101] " llozano at google dot com
2013-08-08  6:41 ` mpolacek at gcc dot gnu.org
2013-08-08 20:46 ` llozano at google dot com
2014-04-08 15:24 ` dichlofos-mv at yandex dot ru
2021-12-23  6:36 ` pinskia at gcc dot gnu.org [this message]

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-58101-4-Kh8nVo33Tp@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).