zserio icon indicating copy to clipboard operation
zserio copied to clipboard

Offset of non-present optional member is ignored

Open mikir opened this issue 3 years ago • 1 comments

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.

mikir avatar Apr 30 '21 06:04 mikir

Because we cannot break backward binary compatibility at the moment and because of effort, we postpone this issue.

mikir avatar May 04 '21 12:05 mikir