(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
Warray-bounds-16.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O3 -Warray-bounds" } */
       3  
       4  typedef struct foo {
       5      unsigned char foo_size;
       6      int buf[4];
       7      const char* bar;
       8  } foo;
       9  
      10  const foo *get_foo(int index);
      11  
      12  static int foo_loop(const foo *myfoo) {
      13      int i;
      14      if (myfoo->foo_size < 3)
      15          return 0;
      16      for (i = 0; i < myfoo->foo_size; i++) {
      17          if (myfoo->buf[i] != 1) /* { dg-bogus "above array bounds" } */
      18              return 0;
      19      }
      20  
      21      return 1;
      22  }
      23  
      24  static int run_foo(void) {
      25      int i;
      26      for (i = 0; i < 1; i++) {
      27          const foo *myfoo = get_foo(i);
      28          if (foo_loop(myfoo))
      29              return 0;
      30      }
      31      return -1;
      32  }
      33  
      34  typedef struct hack {
      35      int (*func)(void);
      36  } hack;
      37  
      38  hack myhack = {
      39      .func = run_foo,
      40  };