Unexpected warning in juce_Array.h

Hi there,

I'm using Array from juce with my own Object, somethink like this:  Array<MyClass, CriticalSection> 

But I get a warning in the juce_Array.h:

...juce_Array.h:1094:22: Destination for this 'memmove' call is a pointer to dynamic class 'myNameSpace::MyClass'; vtable pointer will be overwritten.

This is the line in the removeInternal function that is giving me the warning:

memmove (e, e + 1, ((size_t) numberToShift) * sizeof (ElementType));

Am I missing something? Thanks for the help!

I guess: "The Array class can be used to hold simple, non-polymorphic objects as well as primitive types..." (from the Documentation).

Is that your "MyClass" contains virtual functions (-that implies vtable pointer-) and so is polymorphic?

MyClass implements an interface, how can I fix it?


You can't memove complex classes like that. Use an OwnedArray instead and allocate your objects on the heap.