Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/20120427-2.c

raw
1 /* { dg-additional-options "-fpermissive" } */
2
3 typedef struct sreal
4 {
5 unsigned sig; /* Significant. */
6 int exp; /* Exponent. */
7 } sreal;
8
9 sreal_compare (sreal *a, sreal *b)
10 {
11 if (a->exp > b->exp)
12 return 1;
13 if (a->exp < b->exp)
14 return -1;
15 if (a->sig > b->sig)
16 return 1;
17 if (a->sig < b->sig)
18 return -1;
19 return 0;
20 }
21
22 sreal a[] = {
23 { 0, 0 },
24 { 1, 0 },
25 { 0, 1 },
26 { 1, 1 }
27 };
28
29 int main()
30 {
31 int i, j;
32 for (i = 0; i <= 3; i++) {
33 for (j = 0; j < 3; j++) {
34 if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();
35 if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();
36 if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();
37 }
38 }
39 return 0;
40 }