public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gccbugs at dima dot secretsauce.net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/97261] New: gcc-10 produces invalid -Warray-bounds warning
Date: Thu, 01 Oct 2020 03:32:14 +0000	[thread overview]
Message-ID: <bug-97261-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 97261
           Summary: gcc-10 produces invalid -Warray-bounds warning
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbugs at dima dot secretsauce.net
  Target Milestone: ---

Hi. I'm seeing gcc-10 flag a warning that I'm pretty sure is incorrect. gcc-9
and older did not warn about this (although that's probably because they
weren't looking for these kinds of problems).

Recipe:

1. save the attached as tst.c

2. gcc-10 -Wall -Wextra -Wno-unused-variable -fPIC -O3 -c -o tst.o tst.c

I see this:



tst.c: In function 'f':
tst.c:21:17: warning: array subscript -1 is outside array bounds of 'double[1]'
[-Warray-bounds]
   21 |     const ab_t* ab = (ab_t*)(pb - 1);
      |                 ^~
tst.c:16:13: note: while referencing 'b'
   16 |     double  b  = 4.;
      |             ^



I believe this is false. Inside g(), ab->a is indeed out-of-bounds, but ab->b
is not. And I only use ab->b. Taking away -fPIC or -O3 makes the warning go
away. Making g() static makes it go away also.

I'm using gcc-10 from Debian. Package version 10.1.0-5.

Thanks!

             reply	other threads:[~2020-10-01  3:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01  3:32 gccbugs at dima dot secretsauce.net [this message]
2020-10-01  3:32 ` [Bug c/97261] " gccbugs at dima dot secretsauce.net
2020-10-01  6:26 ` rguenth at gcc dot gnu.org
2020-10-01  7:06 ` gccbugs at dima dot secretsauce.net
2020-10-01  7:54 ` rguenth at gcc dot gnu.org
2020-10-01 15:18 ` [Bug c/97261] distinguish invalid subscripts from invalid addresses in -Warray-bounds msebor 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-97261-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).