public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/109215] warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct lock_class_key[3]’
Date: Mon, 20 Mar 2023 14:27:37 +0000	[thread overview]
Message-ID: <bug-109215-4-ckxqZkX6b8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109215-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
The minimized testcase:

--cut here--
#define SB_FREEZE_COMPLETE 4

struct lock_class_key { };

struct file_system_type {
 struct lock_class_key s_writers_key[(SB_FREEZE_COMPLETE - 1)];
 struct lock_class_key i_lock_key;
};

void foo (struct file_system_type *type)
{
  for (int i = 0; i < (SB_FREEZE_COMPLETE - 1); i++)
    __builtin_printf ("%p\n", &type->s_writers_key[i]);
}
--cut here--

gcc -O2 -Wall:

super-i.c: In function ‘foo’:
super-i.c:13:5: warning: array subscript 0 is outside the bounds of an interior
zero-length array ‘struct lock_class_key[3]’ [-Wzero-length-bounds]
   13 |     __builtin_printf ("%p\n", &type->s_writers_key[i]);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
super-i.c:6:24: note: while referencing ‘s_writers_key’
    6 |  struct lock_class_key s_writers_key[(SB_FREEZE_COMPLETE - 1)];
      |                        ^~~~~~~~~~~~~

  reply	other threads:[~2023-03-20 14:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 14:26 [Bug c/109215] New: " ubizjak at gmail dot com
2023-03-20 14:27 ` ubizjak at gmail dot com [this message]
2023-03-20 15:11 ` [Bug tree-optimization/109215] [13 Regression] wrong " pinskia at gcc dot gnu.org
2023-03-20 15:11 ` pinskia at gcc dot gnu.org
2023-03-20 16:40 ` jakub at gcc dot gnu.org
2023-03-20 17:20 ` jakub at gcc dot gnu.org
2023-03-20 17:42 ` jakub at gcc dot gnu.org
2023-03-20 18:51 ` jakub at gcc dot gnu.org
2023-03-21  8:11 ` rguenth at gcc dot gnu.org
2023-03-21 10:07 ` cvs-commit at gcc dot gnu.org
2023-03-21 10:07 ` jakub 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-109215-4-ckxqZkX6b8@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).