Re: vtable issue

Tech-Archive recommends: Fix windows errors by optimizing your registry



Zoo vtable actually have 3 entries. This seems an issue with MS debugger. To
verify I added a
public void test(){}; in Zoo and modified the main as-

void main() {
Zoo *p = new Zoo;
p->func();
p->foo();
p->goo();
p->test();
}

Check the disaessmbly, It is-

p->func();
00411D9D mov eax,dword ptr [p]
00411DA0 mov edx,dword ptr [eax]
00411DA2 mov esi,esp
00411DA4 mov ecx,dword ptr [p]
00411DA7 mov eax,dword ptr [edx]
00411DA9 call eax
00411DAB cmp esi,esp
00411DAD call @ILT+485(__RTC_CheckEsp) (4111EAh)
p->foo();
00411DB2 mov eax,dword ptr [p]
00411DB5 mov edx,dword ptr [eax]
00411DB7 mov esi,esp
00411DB9 mov ecx,dword ptr [p]
00411DBC mov eax,dword ptr [edx+4]
00411DBF call eax
00411DC1 cmp esi,esp
00411DC3 call @ILT+485(__RTC_CheckEsp) (4111EAh)
p->goo();
00411DC8 mov ecx,dword ptr [p]
00411DCB add ecx,4
00411DCE mov eax,dword ptr [p]
00411DD1 mov edx,dword ptr [eax+4]
00411DD4 mov esi,esp
00411DD6 mov eax,dword ptr [edx+4]
00411DD9 call eax
00411DDB cmp esi,esp
00411DDD call @ILT+485(__RTC_CheckEsp) (4111EAh)
p->test();
00411DE2 mov ecx,dword ptr [p]
00411DE5 call Zoo::test (4112A8h)

It clearly show that first 3 call are through vtable.

Regards,
Manish Agarwal

"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6F1545AF-E2B7-45BB-B282-B078DDF51B3A@xxxxxxxxxxxxxxxx
Hi Stuart,


I am totally confused. Maybe because of my bad description. I am writing
pure C++ code, no IDL/COM/MIDL this time. :-)

I don't know for sure, but my guess is that because the inheritance is
non-public the derived classes IFoo and IGoo don't have to provide the
vtable portion of IBase.

I have tried to make inheritance public, but still the same result. Here
is
my code. Any ideas? Do you think whether foo and goo should be in vtable?

class IBase
{
public:
virtual void func() = 0;
};

class IFoo : public IBase
{
public:
virtual void foo() { cout << "IFoo : IBase" << endl; }
};

class IGoo : public IBase
{
public:
virtual void goo() { cout << "IGoo : IBase" << endl; }
};

class Zoo : public IFoo, public IGoo
{
public:
virtual void func() {cout << "Zoo : IBase" << endl; }
};

int main()
{
Zoo z;

return 0;
}


regards,
George


.



Relevant Pages