Debian Codegraph @

gcc/testsuite/gdc.test/runnable/test21357.d

raw
1 // https://issues.dlang.org/show_bug.cgi?id=21357
2 // PERMUTE_ARGS:
3 struct BatchState
4 {
5 int[10] arr;
6
7 BatchState copy()
8 {
9 auto ret = BatchState(arr);
10 arr[0] += 1;
11 return ret;
12 }
13 }
14
15 struct GrayArea
16 {
17 BatchState low;
18
19 this(this)
20 {
21 low = low.copy;
22 }
23 }
24
25 void main()
26 {
27 GrayArea a;
28 a.low.arr[0] = 1;
29 GrayArea b;
30 b.low.arr[0] = 4;
31 b = a; // calls the postblit
32
33 assert(a.low.arr[0] == 1);
34 assert(b.low.arr[0] == 1);
35 }