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?
Hi Henry,
CodeWarrior 6.4 is an old version and many bugs have been fixed since that version, have you tried using CodeWarrior 10.7 which is the newest version and see if the same problem is present?
CodeWarrior for Microcontrollers-Eclipse IDE|NXP
Let me know the results!
Best Regards,
Carlos Mendoza
Technical Support Engineer
Hi,
I have tried to use this new version, but as you know, the new eclipse based codewarrior can not translate the project file automatically, I spent more than three days to do this manually but failed.
For our legacy project, changing the compiler is impossible, the only thing I want to know is that whether it is a known issue.
And can you give me the bug list of Version 6.4, then we can avoid this type of problems. Because our product is a Safety product and has a SIL1 certification, our management are very worried about this problem.
Thanks.