summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr46675.c
blob: 7493f0e6032bd438f50aa2dd06c7afadb19ae0b9 (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
/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);

int j;

void
__attribute__((noinline))
foo (int n)
{
  int npairs, i;
  npairs = n - (-__INT_MAX__ - 1);

  if (npairs > 0)
    for (i = 0; i < npairs; i++)
      j++;
}

int
main ()
{
  foo (5 - __INT_MAX__ - 1);

  if (j != 5)
    abort ();

  return 0;
}