]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/runnable/test17246.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / runnable / test17246.d
1 /* REQUIRED_ARGS:
2 * OPTIONAL_ARGS:
3 */
4
5 // https://issues.dlang.org/show_bug.cgi?id=17246
6
7 struct Foo
8 {
9 int* rc;
10 this(int val)
11 {
12 rc = new int;
13 (*rc) = 1;
14 }
15 this(this)
16 {
17 (*rc)++;
18 }
19 ~this()
20 {
21 if (rc)
22 {
23 assert(*rc > 0);
24 (*rc)--;
25 }
26 }
27 }
28
29 struct Bar
30 {
31 Foo foo;
32 this(Foo foo, bool)
33 {
34 this.foo = foo;
35 }
36 }
37
38 bool fun(bool val) { return !val; }
39
40 auto genBar(bool flag)
41 {
42 return flag ? Bar() : Bar(Foo(10), fun(!flag));
43 }
44
45 int main(string[] args)
46 {
47 auto bar = genBar(args.length == 0);
48 return 0;
49 }
50