I am having a problem with some very basic functionality of the
SparcWorks C++ 4.2 compiler running on a Sparc Ultra-5. A program will
die from a SIGABRT and say: "Run-time error, libC: 'delete[]' does not
correspond to any new[]' ". It appears to be related to the fact that I
am deleteing an a array of derived objects. Unless we are missing
something really obvious, it looks like a bug in the compiler. I
compile with 'CC -g0 test.cxx -o testprog.' Any help is greatly
appreciated.
Here is a simple test case:
class baseItem {
public:
baseItem() {};
virtual ~baseItem();
};
baseItem::~baseItem() { }
class derivedItem : public baseItem {
public:
derivedItem() : derivedItemValue(0) {};
virtual ~derivedItem();
private:
int derivedItemValue;
};
derivedItem::~derivedItem() {}
int main()
{
baseItem* itemList = new derivedItem[10];
delete [] itemList;
return(0);
}