struct S1 { struct S2 // must be 8 bytes in size { uint a, b; } S2 s2; alias s2 this; } void test() { S1 c; c = c + c; } I'm not sure what's going on - particularly why this even gets to the backend.
Doesn't ICE with 2.056 anymore, but it compiles and produces senseless code: _Dmain: push RBP mov RBP,RSP sub RSP,8 lea RAX,-8[RBP] xor RCX,RCX mov [RAX],RCX lea RDX,-8[RBP] add RDX,-8[RBP] mov -8[RBP],RDX xor EAX,EAX leave ret
This is a regression of fixing bug 6546. The expression c + c runs semantics with alias this expansion in this order: BinExp::op_overload( c + c ) BinExp::op_overload( c.s2 + c ) BinExp::op_overload( c.s2 + s.s2 ) // no operator overloading BinExp::typeCombine( c.s2 + s.s2 ) // 1 BinExp::typeCombine( c.s2 + c ) // 2 BinExp::typeCombine( c + c ) // And BinExp::typeCombine cause error only when both types of sides are same. Therefore, typeCombine rejects #1, but not #2.
https://github.com/D-Programming-Language/dmd/pull/493
https://github.com/D-Programming-Language/dmd/commit/475bd326462105c4422921aa485aed276597940d