| 1 |
/* It is not clear whether this test is conforming. See DR#236 |
| 2 |
http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_236.htm. However, |
| 3 |
there seems to be consensus that the presence of a union to aggregate |
| 4 |
struct s1 and struct s2 should make it conforming. */ |
| 5 |
void abort(void); |
| 6 |
|
| 7 |
struct s1 { double d; }; |
| 8 |
struct s2 { double d; }; |
| 9 |
union u { struct s1 x; struct s2 y; }; |
| 10 |
|
| 11 |
double f(struct s1 *a, struct s2 *b) |
| 12 |
{ |
| 13 |
a->d = 1.0; |
| 14 |
return b->d + 1.0; |
| 15 |
} |
| 16 |
|
| 17 |
int main() |
| 18 |
{ |
| 19 |
union u a; |
| 20 |
a.x.d = 0.0; |
| 21 |
if (f (&a.x, &a.y) != 2.0) |
| 22 |
abort (); |
| 23 |
return 0; |
| 24 |
} |