comparison gcc/testsuite/gcc.dg/pr83373.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* PR middle-end/83373 - False positive reported by -Wstringop-overflow
2 { dg-do compile }
3 { dg-options "-O2 -Wstringop-overflow" } */
4
5 typedef __SIZE_TYPE__ size_t;
6
7 char buf[100];
8
9 void get_data (char*);
10
11 __attribute__ ((nonnull(1, 2)))
12 inline char* my_strcpy (char* dst, const char* src, size_t size)
13 {
14 size_t len = __builtin_strlen (src);
15 if (len < size)
16 __builtin_memcpy (dst, src, len + 1);
17 else
18 {
19 __builtin_memcpy (dst, src, size - 1); /* { dg-bogus "\\\[-Wstringop-oveflow]" } */
20 dst[size - 1] = '\0';
21 }
22
23 return dst;
24 }
25
26 void test(void)
27 {
28 char data[20] = "12345";
29
30 get_data (data);
31
32 my_strcpy (buf, data, sizeof buf);
33 }