PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20050218-1.c
blob104174f923a802bd0eda4561b9a365032dc3aae4
1 /* PR tree-optimization/19828 */
2 typedef __SIZE_TYPE__ size_t;
3 extern size_t strlen (const char *s);
4 extern int strncmp (const char *s1, const char *s2, size_t n);
5 extern void abort (void);
7 const char *a[16] = { "a", "bc", "de", "fgh" };
9 int
10 foo (char *x, const char *y, size_t n)
12 size_t i, j = 0;
13 for (i = 0; i < n; i++)
15 if (strncmp (x + j, a[i], strlen (a[i])) != 0)
16 return 2;
17 j += strlen (a[i]);
18 if (y)
19 j += strlen (y);
21 return 0;
24 int
25 main (void)
27 if (foo ("abcde", (const char *) 0, 3) != 0)
28 abort ();
29 return 0;