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 via email to