* bogus codegen with static opAssign() usage *

kris foo at bar.com
Sun Feb 18 22:01:49 PST 2007


Using static opAssign() apparently has some codegen issues. The 
following snippets are two variations of the same code; the first one is 
correct while the second is broken. Only flag enabled is -g. First, the 
operational version, which invokes this.opAssign() explicitly:

; FileProxy parent = this.opAssign(this.parent());
mov	EAX,-010h[EBP]
call	near ptr _D5tango2io8FilePath8FilePath6parentMFZAa
push	EDX
push	EAX
call	near ptr 
_D5tango2io9FileProxy9FileProxy8opAssignFAaZC5tango2io9FileProxy9FileProxy
mov	-0Ch[EBP],EAX

; char[] name = parent.name;
call	near ptr _D5tango2io8FilePath8FilePath4nameMFZAa
mov	-8[EBP],EAX
mov	-4[EBP],EDX


And now the busted version using opAssign() implicitly:


; FileProxy parent = this.parent();
mov	EAX,-010h[EBP]
call	near ptr _D5tango2io8FilePath8FilePath6parentMFZAa
push	EDX
push	EAX
call	near ptr 
_D5tango2io9FileProxy9FileProxy8opAssignFAaZC5tango2io9FileProxy9FileProxy
 >>> doh! where did the return value go? <<<

; char[] name = parent.name;
mov	EAX,-0Ch[EBP]
call	near ptr _D5tango2io8FilePath8FilePath4nameMFZAa
mov	-8[EBP],EAX
mov	-4[EBP],EDX


It's pretty clear that the broken version is discarding the result of 
the implicit opAssign() call; the assignment is simply being dropped.

I'm copying this here since it'll just get lost amongst the weeds in 
d.bugs. I don't have a small test case: took hours to track this down as 
it was, and it's deep in the Tango library.



More information about the Digitalmars-d mailing list