new sets up incorrect data fields
I have this class, which is derived from std::string. In a certain piece of code, where I allocate an array of these derived classes on the heap, the std::string internal data pointer (_M_p) is not setup correctly for some reason (in this particular case it point to address 0x10, which is obviously out of bounds), so that on subsequent assignment to my array, I get segfaults:
where m_derivedArray, is a member of some class. And yes, i is within the range 0 <= i < x, I checked that.
m_derivedArray = new Derived[x]; // <-- internal data pointer of std::string is setup incorrectly for some reason
Derived[i] = ""; // <-- segfault
Unfortunately I am not able to reproduce the problem in a short program, the complete code is too complicated too post here (big project), and in other instances of the code, the allocation seems to be working fine.
Does anyone have any hints on how to debug this problem? As the problem _seems_ to occur in new I am clueless. I am working on a linux platform and compiling with g++ if that's any help.