]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/Wstringop-overflow-63.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-63.c
1 /* PR middle-end/92936 - missing warning on a past-the-end store to a PHI
2 Test case derived from gcc/opts-common.c.
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
5
6 typedef __SIZE_TYPE__ size_t;
7
8 char* f (const void*, ...);
9
10 const char *
11 candidates_list_and_hint (const char *arg, char **str, const char *a[])
12 {
13 size_t len = 0;
14 int i;
15
16 for (i = 0; a[i]; ++i)
17 len += __builtin_strlen (a[i]) + 1;
18
19 char *p = (char*)__builtin_malloc (len);
20 *str = p;
21
22 for (i = 0; a[i]; ++i)
23 {
24 len = __builtin_strlen (a[i]);
25 __builtin_memcpy (p, a[i], len);
26 p[len] = ' ';
27 p += len + 1;
28 }
29
30 p[-1] = '\0'; // { dg-bogus "\\\[-Wstringop-overflow" }
31
32 return f (arg, &a);
33 }