aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr104198.c
blob: de86f49c9dc8a3c89f5a947c5d0bfdbeef37f658 (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
31
32
33
34
35
36
37
/* Make sure if conversion for two instructions does not break
   anything (if it runs).  */

/* { dg-do run } */
/* { dg-options "-O2 -std=c99" } */
/* { dg-require-effective-target int32plus } */

#include <limits.h>
#include <assert.h>

__attribute__ ((noinline))
int foo (int *a, int n)
{
  int min = 999999;
  int bla = 0;
  for (int i = 0; i < n; i++)
    {
      if (a[i] < min)
	{
	  min = a[i];
	  bla = 1;
	}
    }

  if (bla)
    min += 1;
  return min;
}

int main()
{
  int a[] = {2, 1, -13, INT_MAX, INT_MIN, 0};

  int res = foo (a, sizeof (a) / sizeof (a[0]));

  assert (res == (INT_MIN + 1));
}