PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / pr48022-1.c
blob14eb550307cbc7eea5e922c864fd5354bba7dfae
1 /* PR tree-optimization/48022 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -Wstrict-overflow" } */
5 int
6 foo (const char *x)
8 unsigned long l = 1;
9 const unsigned char *s = (const unsigned char *) (const char *) (x);
10 int r = s[0] - ((const unsigned char *) (const char *) ("/"))[0];
11 if (l > 0 && r == 0)
12 r = (s[1] - ((const unsigned char *) (const char *) ("/"))[1]);
13 return r;