ClipContiguousMemory called for char* not template types T*
Created by: germasch
This is a follow-up from #1254, where looking at that more, I think it points to something fishy, but I can't tell whether it's an issue that can be hit in real life.
helper::ClipContiguousMemory
gets instantiated for std::string
when it's used from BP3Deserializer
(and BP4), I believe in two places: In ClipMemory
and in PostDataRead
.
helper::ClipContiguousMemory
does an reinterpret_cast<char*>
on its T* dest
argument, and then calls CopyContiguousMemory
(adiosMemory.inl
)
char *rawVariableData = reinterpret_cast<char *>(dest);
CopyContiguousMemory(contiguousMemory + contiguousStart, stride,
rawVariableData + variableStart,
endianReverse);
The cast of a std::string *
to a char *
and then operating on the raw memory is highly likely broken, as obviously std::string
is not a POD type. I only know that this gets instantiated, though, not that it ever actually gets called.
Second, and more generally (not specific to std::string), the endianReverse
arg in the call above won't work for any type, since the info on the actual type has been eliminated by casting to char *
, so CopyContiguousMemory
will think it's char
data and (I suppose) not reorder anything.