libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-44.c
blob709d0046b8c55ae0a35df7409470dd077037f5c1
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Warray-bounds" } */
4 int foo(unsigned int state, unsigned char * p, unsigned int p_len)
6 static char const pattern[] = "abcd";
7 static unsigned const pattern_length = sizeof(pattern) - 1;
9 if (p_len == 1) {
10 return state;
13 if (state < pattern_length &&
14 p_len == (pattern_length - state) &&
15 (!__builtin_constant_p(p_len) ?
16 __builtin_memcmp(p, pattern + state, p_len) :
17 ((unsigned char*)p)[6] == ((unsigned char*)pattern + state)[6] /* { dg-bogus "array bounds" } */
18 )) {
20 return 4;
22 return 1;