2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20020402-1.c
blobfe2a6f657b2cf56c279430976929faf2f7cf62b0
1 /* derived from PR c/2100 */
3 extern void abort ();
4 extern void exit (int);
6 #define SMALL_N 2
7 #define NUM_ELEM 4
9 int main(void)
11 int listElem[NUM_ELEM]={30,2,10,5};
12 int listSmall[SMALL_N];
13 int i, j;
14 int posGreatest=-1, greatest=-1;
16 for (i=0; i<SMALL_N; i++) {
17 listSmall[i] = listElem[i];
18 if (listElem[i] > greatest) {
19 posGreatest = i;
20 greatest = listElem[i];
24 for (i=SMALL_N; i<NUM_ELEM; i++) {
25 if (listElem[i] < greatest) {
26 listSmall[posGreatest] = listElem[i];
27 posGreatest = 0;
28 greatest = listSmall[0];
29 for (j=1; j<SMALL_N; j++)
30 if (listSmall[j] > greatest) {
31 posGreatest = j;
32 greatest = listSmall[j];
37 if (listSmall[0] != 5 || listSmall[1] != 2)
38 abort ();
39 exit (0);