gcc/testsuite/g++.dg/torture/pr41186.C
raw| 1 | /* { dg-do run } */ |
| 2 | |
| 3 | struct Foo { |
| 4 | Foo() {}; |
| 5 | int i; |
| 6 | short f; |
| 7 | }; |
| 8 | struct Bar : public Foo { |
| 9 | Bar() {}; |
| 10 | short b; |
| 11 | }; |
| 12 | |
| 13 | extern "C" void abort(void); |
| 14 | |
| 15 | int main() |
| 16 | { |
| 17 | Bar b1, b2; |
| 18 | b2.i = 0; |
| 19 | b1.f = 0; |
| 20 | b1.b = 1; |
| 21 | b2.f = 1; |
| 22 | b2.b = 2; |
| 23 | static_cast<Foo&>(b1) = static_cast<Foo&>(b2); |
| 24 | if (b1.i != 0 || b1.b != 1) |
| 25 | abort (); |
| 26 | if (b1.f != 1) |
| 27 | abort (); |
| 28 | return 0; |
| 29 | } |