PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / pr81292-2.c
blobc1c507f982e94ef224dcf82a66a36e2f4408af60
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fdump-tree-strlen" } */
4 #include "strlenopt.h"
6 char a[] = { 0, 'a', 0, 'b', 'c', 0, 'd', 'e', 'f', 0 };
8 int __attribute__ ((noinline, noclone))
9 f1 (void)
11 a[0] = '1';
12 a[strlen (a)] = '2';
13 a[strlen (a)] = '3';
14 return strlen (a);
17 int __attribute__ ((noinline, noclone))
18 f2 (char *a)
20 a[0] = '1';
21 a[strlen (a)] = '2';
22 a[strlen (a)] = '3';
23 return strlen (a);
26 int
27 main (void)
29 char b[] = { 0, 0, 'a', 'b', 0, 0 };
30 if (f1 () != 9 || f2 (b) != 5)
31 __builtin_abort ();
32 return 0;
35 /* { dg-final { scan-tree-dump-times "strlen \\(" 6 "strlen" } } */