(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
pr71132.c
       1  /* { dg-do compile } */
       2  /* { dg-additional-options "-Wno-stringop-overflow" } */
       3  /* The loop below writes past the end of the global object a.
       4     When the loop is transformed into a call to memcpy the buffer
       5     overflow is detected and diagnosed by the -Wstringop-overflow
       6     option enabled by default.  */
       7  
       8  typedef unsigned size_t;
       9  struct {
      10      unsigned char buf[sizeof(long)];
      11  } a;
      12  size_t b;
      13  int main()
      14  {
      15    size_t c, i;
      16    unsigned char *d;
      17    for (; c < sizeof(long);)
      18      {
      19        d = a.buf;
      20        b = 0;
      21        for (; b < i; b++)
      22  	*d++ = '\0';
      23        for (; c < b; c++)
      24  	*d++ = 'a';
      25        c = 0;
      26        for (; i < sizeof(long); i++)
      27  	;
      28      }
      29  }