-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Labels
Description
I did my best to narrow this problem down. It looks like flatc.exe produces wrong padding for fixed arrays of structs in c#.
Fixed size array of longs is generated correctly:
builder.Prep(8, 80);
builder.PutLong(Int2);
for (int _idx0 = 8; _idx0 > 0; _idx0--) {
builder.PutLong(IntStruct[_idx0-1]);
}
builder.Pad(4); // <- correctly placed padding
builder.PutInt(Int1);But in the case of array of structs:
builder.Prep(8, 80);
builder.PutLong(Int2);
builder.Pad(4); // <- incorrectly placed padding, unnecessary padding of 4 bytes
for (int _idx0 = 8; _idx0 > 0; _idx0--) {
builder.Prep(8, 8); // same thing, results in one more alignment, producing extra 4 bytes
builder.PutLong(int_struct_LongField[_idx0-1]);
}
builder.PutInt(Int1);Both schemes should result in exactly the same buffer layout: there is no difference in laying out array of longs and array of structs that contain a single long.
As you can see in the attachment, incorrect padding leads to everything to be offset by a few bytes
Thank you!
Reactions are currently unavailable