blob: 778d62da07266e21b0a71f7ca11299f77b9d22f4 [file] [log] [blame]
/* REQUIRED_ARGS:
* OPTIONAL_ARGS:
*/
// https://issues.dlang.org/show_bug.cgi?id=17246
struct Foo
{
int* rc;
this(int val)
{
rc = new int;
(*rc) = 1;
}
this(this)
{
(*rc)++;
}
~this()
{
if (rc)
{
assert(*rc > 0);
(*rc)--;
}
}
}
struct Bar
{
Foo foo;
this(Foo foo, bool)
{
this.foo = foo;
}
}
bool fun(bool val) { return !val; }
auto genBar(bool flag)
{
return flag ? Bar() : Bar(Foo(10), fun(!flag));
}
int main(string[] args)
{
auto bar = genBar(args.length == 0);
return 0;
}