https://issues.dlang.org/show_bug.cgi?id=19793
Issue ID: 19793
Summary: no postblit is called if cast is used for structs
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
struct S(T)
{
size_t* counter;
this(this)
{
if (counter)
++counter[0];
}
~this()
{
if (counter)
--counter[0];
}
static S create()
{
return S(new size_t(1));
}
}
auto constOf(S!int a)
{
return cast(S!(const int)) a;
}
void main()
{
auto s = S!int.create;
assert(s.counter[0] == 1); // pass
auto a = constOf(s);
assert(s.counter[0] == 2); // fails
}
--