[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gcc.dg / pr83373.c
blob6b0de0997c0485c8650735ab1cb7c4dfa9e4e2a8
1 /* PR middle-end/83373 - False positive reported by -Wstringop-overflow
2 { dg-do compile }
3 { dg-options "-O2 -Wstringop-overflow" } */
5 typedef __SIZE_TYPE__ size_t;
7 char buf[100];
9 void get_data (char*);
11 __attribute__ ((nonnull(1, 2)))
12 inline char* my_strcpy (char* dst, const char* src, size_t size)
14 size_t len = __builtin_strlen (src);
15 if (len < size)
16 __builtin_memcpy (dst, src, len + 1);
17 else
19 __builtin_memcpy (dst, src, size - 1); /* { dg-bogus "\\\[-Wstringop-oveflow]" } */
20 dst[size - 1] = '\0';
23 return dst;
26 void test(void)
28 char data[20] = "12345";
30 get_data (data);
32 my_strcpy (buf, data, sizeof buf);