| 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 |
return -(a->sig < b->sig); |
| 18 |
} |
| 19 |
|
| 20 |
sreal a[] = { |
| 21 |
{ 0, 0 }, |
| 22 |
{ 1, 0 }, |
| 23 |
{ 0, 1 }, |
| 24 |
{ 1, 1 } |
| 25 |
}; |
| 26 |
|
| 27 |
int main() |
| 28 |
{ |
| 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(); |
| 35 |
} |
| 36 |
} |
| 37 |
return 0; |
| 38 |
} |