D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6736 - Regression(2.054): ICE (cgcod.c 1672) with alias this and certain structs
Summary: Regression(2.054): ICE (cgcod.c 1672) with alias this and certain structs
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: accepts-invalid, diagnostic, patch, wrong-code
Depends on:
Blocks:
 
Reported: 2011-09-27 08:28 UTC by Vladimir Panteleev
Modified: 2011-11-05 13:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2011-09-27 08:28:32 UTC
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.
Comment 1 Trass3r 2011-11-03 09:27:13 UTC
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
Comment 2 Kenji Hara 2011-11-03 21:17:15 UTC
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.