view gcc/testsuite/gcc.dg/Wstringop-overflow-16.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

/* 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];
  }
}