I'm maintaining an old product based on MCF5208, I found some code behavior is strange, so I wrote a simple test code to do test. I think I found a compiler bug when using C++ virtual function.
class A
{
public:
virtual int Size()=0;
};
class B:public A
{
public:
virtual int Size()
{
return 10;
}
};
static B b;
void test(void)
{
A *p = &b;
int x = b.Size();
int y= p->Size();
int z=x+y;
}
When code run to p->Size(); it will crash.

I have decompiled the code and run it in step mode, I found it crashed in the line I marked red.
Is this a real problem or it just because of some incorrect compiler settings?