[Issue 19793] New: no postblit is called if cast is used for structs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 8 11:27:58 UTC 2019
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: nobody at puremagic.com
Reporter: ilyayaroshenko at gmail.com
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
}
--
More information about the Digitalmars-d-bugs
mailing list