summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr40087.c
blob: 22e2b629ed79f8a818469b90956605eb457c2a91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* { dg-do run } */
/* { dg-options "-O1 " } */

extern void abort (void);

static void __attribute__((always_inline))
reverse(int *first, int *last)
{
  if (first == last--) 
    return;
  while (first != last)
    {
      int t = *first;
      *first = *last;
      *last = t;
      if (++first == last--)
        break;
    }
}

int main()
{
  int seq[] = { 1, 2, 3, 4, 5, 6, 7, 8 };

  reverse(seq, seq + 8);
  if (seq[3] != 5 || seq[4] != 4)
    abort ();

  return 0;
}