Marc Friesen

Bug Report: delete fails when virtual base class has virtual destructor - CW S12X V5 CHC12.EXE

Discussion created by Marc Friesen on Jun 1, 2011
Latest reply on Jun 6, 2011 by Tom Thompson

The example shown below reproduces the problem. This was compiled in a brand new C++ project with no other user code involved. Sample project attached to this post for reference.


Here are two changes that will prevent the error (but not solve the problem):

- make the ~Entity() destructor non-virtual

- do not use virtual inheritance for Object and Interface


Here is a work-around:

- delete '(Entity*)ptr' instead of 'ptr'



#include <hidef.h>#include "derivative.h"class Entity{    public:        virtual ~Entity() { }};class Object : public virtual Entity { /*...*/ };class Interface : public virtual Entity { /*...*/ };class MyClass : public Object, public Interface{    public:        virtual ~MyClass() { }};void main(void){    MyClass* ptr = new MyClass;        delete ptr;    // Error : C5701: Internal Error #604 in 'f:\build\Products\Hiware\cw_hc12_Build_Tools\hiware\src\ccpp\ccpp.cpp'    // while compiling file 'C:\dev\projects\spike\test_project\Sources\main.cpp', procedure 'main', please report to Freescale        EnableInterrupts;    for(;;) { _FEED_COP(); }}