The array implementation for arbitrary serialisable objects expects the object type to be of fixed size after serialization. This size is determined by creating an object using the default constructor and then serializing it.
If later on an object is added that serialises to a different number of bytes (e.g. because it contains dynamically allocated members that differ in size compared to the test-object created by the default constructor), this results in an obscure cereal error later on.
To provide a more understandable error message to the user, check the size of each element when adding it to the array and throw a runtime_error if it does not match the expected size.
Let me know if you think adding fmt just for this is overkill, then I'll remove that part.
How I Tested
With my current work on the o80 Vicon driver (where I ran exactly into this issue).
By running a TriFinger simulation demo that uses the multi-process time series.
I fulfilled the following requirements
[x] All new code is formatted according to our style guide (for C++ run clang-format, for Python, run flake8 and fix all warnings).
[x] All new functions/classes are documented and existing documentation is updated according to changes.
[x] No commented code from testing/debugging is kept (unless there is a good reason to keep it).
Description
The
array
implementation for arbitrary serialisable objects expects the object type to be of fixed size after serialization. This size is determined by creating an object using the default constructor and then serializing it. If later on an object is added that serialises to a different number of bytes (e.g. because it contains dynamically allocated members that differ in size compared to the test-object created by the default constructor), this results in an obscure cereal error later on.To provide a more understandable error message to the user, check the size of each element when adding it to the array and throw a runtime_error if it does not match the expected size.
Let me know if you think adding fmt just for this is overkill, then I'll remove that part.
How I Tested
I fulfilled the following requirements