2012-04-27 Paolo Bonzini <bonzini@gnu.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20120427-2.c
blobe473a4772a9ee1316fb6ae36c1d76bf9ea78f584
1 typedef struct sreal
3 unsigned sig; /* Significant. */
4 int exp; /* Exponent. */
5 } sreal;
7 sreal_compare (sreal *a, sreal *b)
9 if (a->exp > b->exp)
10 return 1;
11 if (a->exp < b->exp)
12 return -1;
13 if (a->sig > b->sig)
14 return 1;
15 if (a->sig < b->sig)
16 return -1;
17 return 0;
20 sreal a[] = {
21 { 0, 0 },
22 { 1, 0 },
23 { 0, 1 },
24 { 1, 1 }
27 int main()
29 int i, j;
30 for (i = 0; i <= 3; i++) {
31 for (j = 0; j < 3; j++) {
32 if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();
33 if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();
34 if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();
37 return 0;