public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97261] New: gcc-10 produces invalid -Warray-bounds warning
@ 2020-10-01  3:32 gccbugs at dima dot secretsauce.net
  2020-10-01  3:32 ` [Bug c/97261] " gccbugs at dima dot secretsauce.net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gccbugs at dima dot secretsauce.net @ 2020-10-01  3:32 UTC (permalink / raw)
  To: gcc-bugs

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!

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

end of thread, other threads:[~2020-10-01 15:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  3:32 [Bug c/97261] New: gcc-10 produces invalid -Warray-bounds warning gccbugs at dima dot secretsauce.net
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

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