| 1 |
// https://bugzilla.gdcproject.org/show_bug.cgi?id=286 |
| 2 |
// { dg-do run } |
| 3 |
// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } |
| 4 |
|
| 5 |
void main() |
| 6 |
{ |
| 7 |
struct K286 |
| 8 |
{ |
| 9 |
int count; |
| 10 |
this(this) |
| 11 |
{ |
| 12 |
count++; |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
struct S286 |
| 17 |
{ |
| 18 |
int data; |
| 19 |
this(K286 key) |
| 20 |
{ |
| 21 |
data = key.count; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
S286 getData(K286 key) |
| 26 |
{ |
| 27 |
static S286[K286] getCache; |
| 28 |
auto p = key in getCache; |
| 29 |
if (p) |
| 30 |
return *p; |
| 31 |
return (getCache[key] = S286(key)); |
| 32 |
} |
| 33 |
|
| 34 |
auto s = getData(K286()); |
| 35 |
if (s.data == 0) |
| 36 |
assert(0); |
| 37 |
} |