April 08, 2019 [Issue 19793] New: no postblit is called if cast is used for structs | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: ilyayaroshenko@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 } -- |
Copyright © 1999-2021 by the D Language Foundation