gcc/testsuite/g++.dg/init/new29.C
raw| 1 | // PR c++/43951 |
| 2 | // { dg-do run } |
| 3 | // { dg-options "-O2" } |
| 4 | |
| 5 | extern "C" void abort (); |
| 6 | |
| 7 | class Foo |
| 8 | { |
| 9 | public: |
| 10 | Foo () : xxx (1) {}; |
| 11 | const int xxx; |
| 12 | }; |
| 13 | |
| 14 | struct Foo2 |
| 15 | { |
| 16 | Foo foo; |
| 17 | }; |
| 18 | |
| 19 | Foo2 * |
| 20 | bar () |
| 21 | { |
| 22 | return new Foo2; |
| 23 | } |
| 24 | |
| 25 | int |
| 26 | main () |
| 27 | { |
| 28 | Foo2 *p = bar (); |
| 29 | |
| 30 | if (p->foo.xxx != 1) |
| 31 | abort (); |
| 32 | return 0; |
| 33 | } |