[Issue 3634] return value not passed to out contracts of private methods
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 18 22:59:08 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3634
--- Comment #1 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2009-12-18 22:59:08 PST ---
Original code (with "private") fails also with "-O", "-O -inline", and many
others.
Here is simplified case:
class A {
this() {
x_ = 0x40;
}
private:
uint x_;
//public:
uint x()
out(ret) {
pppp(ret);
}
body {
return x_;
}
}
import std.stdio;
void main() { auto a = new A(); }
void pppp(uint xxx) { xxx ++; }
.text._D1t1A1xMFZk segment
assume CS:.text._D1t1A1xMFZk
_D1t1A1xMFZk:
push EBP
mov EBP,ESP
sub ESP,8
mov ECX,8[EAX] // move field x_ to the ECX register
mov -8[EBP],ECX // save ret in EBP[-8]
xor EAX,EAX // set ret = 0
call near ptr _D1t4ppppFkZv at PC32 // call pppp(EAX)
mov EAX,-8[EBP] // restore ret after return from ppp
leave
ret // return
.text._D1t1A1xMFZk ends
When changed to "public":
.text._D1t1A1xMFZk segment
assume CS:.text._D1t1A1xMFZk
_D1t1A1xMFZk:
push EBP
mov EBP,ESP
sub ESP,8
mov -4[EBP],EAX
call near ptr _D9invariant12_d_invariantFC6ObjectZv at PC32
mov EAX,-4[EBP]
mov ECX,8[EAX]
mov -8[EBP],ECX
lea EDX,-8[EBP]
push EDX
call near ptr _D1t1A1xMFZk8__ensureMFKxkZv at PC32
mov EAX,-8[EBP]
leave
ret
nop
nop
nop
.text._D1t1A1xMFZk ends
.text._D1t1A1xMFZk8__ensureMFKxkZv segment
assume CS:.text._D1t1A1xMFZk8__ensureMFKxkZv
_D1t1A1xMFZk8__ensureMFKxkZv:
push EBP
mov EBP,ESP
sub ESP,4
mov ECX,8[EBP] // take address of field x_ and put into
ECX
mov EAX,[ECX] // move content of field x_ into EAX
call near ptr _D1t4ppppFkZv at PC32 // call pppp(EAX)
leave
ret 4 // return
.text._D1t1A1xMFZk8__ensureMFKxkZv ends
_D9invariant12_d_invariantFC6ObjectZv at PC32 is and Object.invariant() from base
class.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list