1 /* Test to verify that -Wstringop-overflow mentions the referenced object
2 { dg-do compile }
3 { dg-options "-O2 -Wall" } */
4
5 static void copy_n (char *d, const char *s, int n)
6 {
7 while (n--)
8 *d++ = *s++;
9 *d = 0; // { dg-warning "writing 1 byte into a region of size 0" }
10 }
11
12 void sink (void*);
13
14 void call_copy_n (const char *s)
15 {
16 char a[7]; // { dg-message "at offset 7 into destination object 'a'" }
17 copy_n (a, "1234567", 7);
18 sink (a);
19 }