public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/99475] New: [10/11 Regression] bogus -Warray-bounds accessing an array element of empty structs
@ 2021-03-08 22:32 msebor at gcc dot gnu.org
  2021-03-08 22:34 ` [Bug tree-optimization/99475] " msebor at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-08 22:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99475
           Summary: [10/11 Regression] bogus -Warray-bounds accessing an
                    array element of empty structs
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

An indirect access to an element of an array of empty structs through a pointer
to such an element triggers a spurious -Warray-bounds warning:

$ cat v.c && gcc -O2 -S -Wall v.c
struct S { } a[5];

void f (void)
{
  a[1] = (struct S) { };   // okay
}

void g (void)
{
  struct S *p = &a[0];
  p[1] = (struct S) { };   // bogus -Warray-bounds
}

v.c: In function ‘g’:
v.c:11:4: warning: array subscript 0 is outside array bounds of ‘struct S[5]’
[-Warray-bounds]
   11 |   p[1] = (struct S) { };
      |   ~^~~
v.c:1:14: note: while referencing ‘a’
    1 | struct S { } a[5];
      |              ^

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

end of thread, other threads:[~2024-05-04  7:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 22:32 [Bug tree-optimization/99475] New: [10/11 Regression] bogus -Warray-bounds accessing an array element of empty structs msebor at gcc dot gnu.org
2021-03-08 22:34 ` [Bug tree-optimization/99475] " msebor at gcc dot gnu.org
2021-03-09  2:40 ` msebor at gcc dot gnu.org
2021-03-09  8:32 ` rguenth at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2022-03-17 19:41 ` msebor at gcc dot gnu.org
2022-06-28 10:43 ` jakub at gcc dot gnu.org
2023-07-07 10:39 ` [Bug tree-optimization/99475] [11 " rguenth at gcc dot gnu.org
2024-04-26 18:21 ` siddhesh at gcc dot gnu.org
2024-05-04  7:42 ` egallager 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).