PR c/53562 - Add -Werror= support for -D_FORTIFY_SOURCE / __builtin___memcpy_chk
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr71132.c
blob2544eb14292a62620cf41410ba86798a3bbea525
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. */
8 typedef unsigned size_t;
9 struct {
10 unsigned char buf[sizeof(long)];
11 } a;
12 size_t b;
13 int main()
15 size_t c, i;
16 unsigned char *d;
17 for (; c < sizeof(long);)
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++)