[Issue 17572] New: unrestricted union erroneously invokes postblit
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Thu Jun 29 06:11:56 PDT 2017
    
    
  
https://issues.dlang.org/show_bug.cgi?id=17572
          Issue ID: 17572
           Summary: unrestricted union erroneously invokes postblit
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: wyrlon at gmx.net
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;
}
--
    
    
More information about the Digitalmars-d-bugs
mailing list