gcc/testsuite/gdc.test/runnable/test21367.d
raw| 1 | // https://issues.dlang.org/show_bug.cgi?id=21367 |
| 2 | |
| 3 | string result = ""; |
| 4 | |
| 5 | struct RCArray(T) |
| 6 | { |
| 7 | T* data; |
| 8 | this(this) |
| 9 | { |
| 10 | result ~= "A"; |
| 11 | } |
| 12 | ~this() |
| 13 | { |
| 14 | result ~= "B"; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | struct Variant(T...) |
| 19 | { |
| 20 | union |
| 21 | { |
| 22 | T payload; |
| 23 | } |
| 24 | this(this) |
| 25 | { |
| 26 | result ~= "C"; |
| 27 | } |
| 28 | |
| 29 | ~this() |
| 30 | { |
| 31 | result ~= "D"; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | alias Ft = Variant!(RCArray!double, RCArray!int); |
| 36 | |
| 37 | void fun(Ft a) {} |
| 38 | void main() |
| 39 | { |
| 40 | Ft a; |
| 41 | Ft b = a; |
| 42 | } |
| 43 | |
| 44 | static ~this() |
| 45 | { |
| 46 | assert(result == "CDD"); |
| 47 | } |