gcc/testsuite/g++.dg/init/value10.C
raw| 1 | // PR c++/51331 |
| 2 | // { dg-do run } |
| 3 | |
| 4 | struct A { |
| 5 | A(): x(10) {} |
| 6 | virtual ~A() {} |
| 7 | |
| 8 | int x; |
| 9 | }; |
| 10 | |
| 11 | struct B: public virtual A { |
| 12 | }; |
| 13 | |
| 14 | struct C: public virtual A { |
| 15 | }; |
| 16 | |
| 17 | struct D: public B, virtual public C { |
| 18 | D(): B(), C() {} // note an explicit call to C() which is auto-generated |
| 19 | }; |
| 20 | |
| 21 | int main() { |
| 22 | D* d = new D(); |
| 23 | |
| 24 | // Crashes here with the following message: |
| 25 | // *** glibc detected *** ./test: free(): invalid next size (fast) |
| 26 | delete d; |
| 27 | } |