cereal
cereal copied to clipboard
Wrong string deserialized in binary but not json?
I am serializing a struct A which contains a few members include two length one std::vectors of struct B. B contains, among other things, a couple of strings. Struct A inherits from another class. Both structs (and the base class of the first) contain serialize methods that simply list all their members.
If I serialize to json, and then deserialize immediately, the result is correct. If I use a binary archive instead, however, then one of the strings in the first std::vector<B> is wrong... it has the value of the corresponding string of the same member in the other std::vector<B>!!
Any idea about what might be going on here or how to diagnose this? If not then I'll start trying to build an isolated repro case to figure out what is happening.
To clarify a little:
struct B {
std::string bad;
std::string good;
};
struct A {
std::vector<B> first;
std::vector<B> second;
};
After deserialization, a.first[0].bad has been made a copy of a.second[0].good. And because we're using GCC <5.0 the string class is using ref counted data, so I know that the good string was copied (either explicitly or incidentally) to the bad string because the pointers to the string characters are identical.
Would need a minimal running example to help further with this.
Have worked around the problem for now, and will likely update the GCC version being used. Will not follow up on this issue unless it recurs (having read about the previous issue with GCC 4.8.x strings, I strongly suspect it is related).