AnsweredAssumed Answered

Problem with CodeWarrior 6.4 and C++ (new/delete)

Question asked by Stefan Kaiser on Jul 31, 2013
Latest reply on Sep 3, 2013 by Pascal Irrle

Hi all,

I am working with CW6.4 on MCF5484 with code written in C for years. I now have to integrate new functionality written in C++ that uses new/delete. Because I have to use dynamic memory management of the RTOS, I wrote 'operator new', 'operator new[]', 'operator delete' and 'operator delete[]' that call the appropriate functions of the RTOS. Single stepping shows that this works correctly.

The problem is, that the compiler generates different code. In some methods 'operator delete[]' is called with the pointer returned by 'operator new[]' and in other methods 8 is subtracted from the pointer before 'operator delete[]' is called (leads to an exception).

Has anyone an idea what I've made wrong or could it be a compiler bug?

Thanks in advance.