1 /* PR tree-optimization/83075 - Invalid strncpy optimization */
3 /* { dg-options "-O2 -Wstringop-overflow" } */
5 typedef __SIZE_TYPE__
size_t;
7 __attribute__((noipa
)) size_t
8 foo (char *p
, char *q
, size_t *r
)
10 size_t n0
= __builtin_strlen (p
);
11 __builtin_strncat (q
, p
, n0
); /* { dg-warning "specified bound depends on the length" } */
12 size_t n1
= __builtin_strlen (p
);
21 __builtin_strcpy (a
, "123");
22 size_t n0
= __builtin_strlen (a
);
23 __builtin_strncat (a
+ 3, a
, n0
); /* { dg-warning "specified bound depends on the length" } */
24 size_t n1
= __builtin_strlen (a
);
28 __builtin_strcpy (a
, "456");
30 if (foo (a
, a
+ 3, &n2
) != 6 || n2
!= 3)
32 if (__builtin_memcmp (a
, "456456\0", sizeof "456456\0"))