aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/undefined-loop-1.c
blob: 80260cc8b01166ed2517d0076c15d5a907b52af7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* Check that loops whose final iteration is undefined are detected.  */
/* { dg-do compile } */
/* { dg-options "-O2 -Waggressive-loop-optimizations" } */

void doSomething(char);

char array[5];

void
foo (void)
{
  int i;
  for (i = 0;
       array[i]  /* { dg-message "note: possible undefined statement is here" } */
       && i < 5; /* { dg-warning "loop exit may only be reached after undefined behavior" } */
       i++)
    doSomething(array[i]);
}