Reputation: 49
I have a deep copy method in a custom container myCont
. I have an instance of an unsorted container that I need to sort and dump. I create a temp container with sorted flag on, call the copy method and Dump. But the app code below creates an empty container and passes that rather than my (loaded) container. Need help figuring out what is going on here. Thanks in advance
void myCont::Copy(const myCont& srcCont)
{
// code to deep copy from srcCont
}
App Code:
fn(x, z, z) {
myCont dC();
dC.setSorted(true);
dC.Copy(sC);
dC.DumpCont();
}
Assembly:
myCont dC();
0000000140323068 mov dl,1
000000014032306A lea rcx,[dC]
0000000140323072 call myCont::myCont (0141E1A01Ah)
0000000140323077 nop
dSet.Copy(sC);
0000000140323078 cmp qword ptr [sC],0
0000000140323081 je CR::evaluate+6FDh (014032308Dh)
0000000140323083 mov byte ptr [rsp+0C2h],1
000000014032308B jmp CR::evaluate+705h (0140323095h)
000000014032308D mov byte ptr [rsp+0C2h],0
0000000140323095 movzx edx,byte ptr [rsp+0C2h]
000000014032309D lea rcx,[rsp+6F0h]
00000001403230A5 call myCont::myCont (0141E1A01Ah) <-WHY THIS CTROL CALL ????????????
00000001403230AA nop
00000001403230AB lea rdx,[rsp+6F0h]
00000001403230B3 lea rcx,[dC]
00000001403230BB call myCont::Copy (0141E1A188h)
00000001403230C0 nop
00000001403230C1 lea rcx,[rsp+6F0h]
00000001403230C9 call myCont::~my Cont(0140009280h)
dC.DumpCont();
00000001403230CE lea rcx,[dC]
00000001403230D6 call myCont::DumpCont(014019B240h)
Upvotes: 0
Views: 64
Reputation: 340208
From the little bit of code you posted:
void myCont::Copy(const myCont& srcCont)
{
// code to deep copy from srcCont
}
this indicates that myCont::Copy()
doesn't return a new myCont
object and it can't modify the srcCont
object. So it's not clear what the Copy()
function is actually supposed to be doing.
Also, myCont dC();
is an instance of the most vexing parse - it's a nop.
Upvotes: 1
Reputation: 2430
This is not a complete example, but since you provided the assembly, I think I can tell what is going on.
sC is converting to a bool (cmp to zero, then set either a one or a zero). You must have an implicit constructor in the myCont class that can convert from a bool. sC is apparently not of type myCont. Is sC a myCont * by any chance?
Upvotes: 2