| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
struct A |
| 4 |
{ |
| 5 |
char a[1]; // must be char array |
| 6 |
}; |
| 7 |
|
| 8 |
struct B |
| 9 |
{ |
| 10 |
A& a() { return ma; } // must be accessed through a getter |
| 11 |
A ma; |
| 12 |
}; |
| 13 |
|
| 14 |
struct C |
| 15 |
{ |
| 16 |
B& b() { return mb; } // must be accessed through a getter |
| 17 |
B mb; |
| 18 |
}; |
| 19 |
|
| 20 |
struct D |
| 21 |
{ |
| 22 |
virtual A getA() = 0; // must be virtual |
| 23 |
}; |
| 24 |
|
| 25 |
void |
| 26 |
foo(D& d) // The D object must not be created locally |
| 27 |
// (so that getA implementation is not known at compile time?) |
| 28 |
{ |
| 29 |
C c; |
| 30 |
for (;;) // must be in a loop |
| 31 |
c.b().a() = d.getA(); |
| 32 |
} |