zserio
zserio copied to clipboard
Offset of non-present optional member is ignored
Currently, offset of non-present optional member is ignored. Meaning if a member with offset is optional, offset is optional as well:
struct Example
{
uint32 byteOffset;
bool hasOptional;
byteOffset:
int32 myOptionalField if hasOptional == true;
int32 myField;
};
In the above code example, if the member hasOptional
is not present then no offset will be checked
and the size will be 65 bits.
However, this is not intuitive for schema writers. It will be more intuitive if offset becomes a property of the structure and it will be always checked without any exception.
Please note, that this change can potentially break backward binary compatibility.
The same problem is for alignment, please see #315.
Because we cannot break backward binary compatibility at the moment and because of effort, we postpone this issue.