summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-overflow-16.c
blob: 11fb05e730a799f58075e0031257df25ca994792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* PR middle-end/91599 - GCC does not say where warning is happening
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

struct charseq {
  unsigned char bytes[0];         // { dg-message "while referencing|object declared here" }
};

struct locale_ctype_t {
  struct charseq *mboutdigits[10];
};

void ctype_finish (struct locale_ctype_t *ctype)
{
  long unsigned int cnt;
  for (cnt = 0; cnt < 20; ++cnt) {
    static struct charseq replace[2];
    replace[0].bytes[1] = '\0';   // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
    ctype->mboutdigits[cnt] = &replace[0];
  }
}