(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
Warray-bounds-44.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -Warray-bounds" } */
       3  
       4  int foo(unsigned int state, unsigned char * p, unsigned int p_len)
       5  {
       6      static char const pattern[] = "abcd";
       7      static unsigned const pattern_length = sizeof(pattern) - 1;
       8  
       9      if (p_len == 1) {
      10          return state;
      11      }
      12  
      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          )) {
      19  
      20          return 4;
      21      }
      22      return 1;
      23  }