Debian Codegraph @

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

raw
1 // https://issues.dlang.org/show_bug.cgi?id=23181
2 void main()
3 {
4 int count;
5 struct HasDtor
6 {
7 ~this() { ++count; }
8 }
9
10 // array[] = elem()
11 // -> creates temporary to construct array and calls destructor.
12 {
13 count = 0;
14 HasDtor[4] dtor1 = HasDtor();
15 assert(count == 1);
16 }
17 assert(count == 5);
18
19 // array[] = array[elem()]
20 // -> constructs array using direct emplacement.
21 {
22 count = 0;
23 HasDtor[2] dtor2 = [HasDtor(), HasDtor()];
24 assert(count == 0);
25 }
26 assert(count == 2);
27 }