1 // Verify that loop optimization takes into account the exception edge
2 // and does not increment I before the call.
3 // { dg-do run }
4 // { dg-options "-O2" }
5 
6 extern "C" void abort();
7 static void bar(char *);
8 
foo(unsigned long element_count,char * ptr)9 static void foo(unsigned long element_count, char *ptr)
10 {
11   unsigned long i;
12   try {
13     for (i = 0; i != element_count; i++, ptr += 8)
14       bar (ptr);
15   }
16   catch (...) {
17     if (i)
18       abort ();
19   }
20 }
21 
bar(char *)22 static void bar(char *)
23 {
24   throw 1;
25 }
26 
main()27 int main()
28 {
29   foo(2, 0);
30 }
31