Debian Codegraph @

gcc/testsuite/gdc.dg/torture/pr101273.d

raw
1 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101273
2 // { dg-do run }
3
4 struct S101273
5 {
6 int x;
7 S101273* impl;
8 this(int x)
9 {
10 this.x = x;
11 this.impl = &this;
12 }
13 ~this() { }
14 }
15
16 S101273 makeS101273()
17 {
18 return S101273(2);
19 }
20
21 S101273 nrvo101273()
22 {
23 S101273 ret = makeS101273();
24 return ret;
25 }
26
27 S101273 rvo101273()
28 {
29 return makeS101273();
30 }
31
32 void main()
33 {
34 auto nrvo = nrvo101273();
35 assert(&nrvo is nrvo.impl);
36
37 auto rvo = rvo101273();
38 assert(&rvo is rvo.impl);
39 }