http://d.puremagic.com/issues/show_bug.cgi?id=2943
Summary: Struct copying in presence of alias member this only copies alias this member Product: D Version: 2.029 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: critical Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: dsim...@yahoo.com When a struct has a member that is alias this'd and that struct is assigned the value of another struct of the same type, only the member of the struct that is alias this'd is copied. Apparently, D tries conversion via alias this *before* assigning as the full struct. Marking this as critical because it can lead to extremely subtle, hard to find bugs in user code with absolutely no warning. import std.stdio; struct Foo { int a; int b; alias b this; } void main() { Foo foo, foo2; foo.a = 1; foo.b = 2; foo2.a = 3; foo2.b = 4; writeln(foo2.a, "\t", foo2.b); // 3 4 foo2 = foo; writeln(foo2.a, "\t", foo2.b); // 3 2 } --