← Back to index
|
Original Bugzilla link
Bug 17572 – unrestricted union erroneously invokes postblit
Status
RESOLVED
Resolution
INVALID
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-29T13:11:00Z
Last change time
2017-07-03T10:29:01Z
Assigned to
nobody
Creator
wyrlon
Comments
Comment #0
by wyrlon — 2017-06-29T13:11:56Z
Expected Behavior: prints 0 Observed Behavior: prints 1 import std.stdio; long post = 0; struct Node { uint val; this(this) { ++post; } } union POD(T) { T val; } POD!Node g; void Put(ref Node val) { g = cast(POD!Node)val; } void main() { auto x = Node(5); x.Put(); post.writeln; }
Comment #1
by kinke — 2017-06-29T19:50:23Z
Not a bug, as the copy and postblit happens correctly when constructing the `cast(POD!Node)val` rvalue, see
https://github.com/ldc-developers/ldc/issues/2185.