public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/92939] missing -Wstringop-overflow on negative index from the end of array
Date: Wed, 10 Jun 2020 18:06:54 +0000	[thread overview]
Message-ID: <bug-92939-4-0E1G0YWWEU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-92939-4@http.gcc.gnu.org/bugzilla/>

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.1.0
             Status|UNCONFIRMED                 |RESOLVED
   Target Milestone|---                         |11.0
      Known to work|                            |11.0
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
After r11-1183 GCC detects the overflow as expected:

$ gcc -O2 -S -Wall -Wextra -Wno-array-bounds pr92939.c

pr92939.c: In function ‘f’:
pr92939.c:12:8: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   12 |   p[1] = 0;    // a[3]    a[3]     a[4]    a[4]    << warns
      |   ~~~~~^~~
pr92939.c:8:8: note: at offset 3 to object ‘a’ with size 3 declared here
    8 |   char a[3], *p = a + n;
      |        ^
pr92939.c:22:9: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
   22 |   p[-2] = 0;   // a[-2]   a[-3]    a[-1]   a[-2]   << should warn
      |   ~~~~~~^~~
pr92939.c:8:8: note: at offset -1 to object ‘a’ with size 3 declared here
    8 |   char a[3], *p = a + n;
      |        ^

      parent reply	other threads:[~2020-06-10 18:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-92939-4@http.gcc.gnu.org/bugzilla/>
2020-06-10 18:02 ` cvs-commit at gcc dot gnu.org
2020-06-10 18:06 ` msebor 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-92939-4-0E1G0YWWEU@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).