forked from dvidelabs/flatcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug report for issue dvidelabs#179 (vector alignment issues).
- Loading branch information
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
namespace Eclectic; | ||
|
||
table Buffer { | ||
data:[uint8]; | ||
} | ||
|
||
enum Fruit : byte { Banana = -1, Orange = 42 } | ||
table FooBar { | ||
meal : Fruit = Banana; | ||
density : long (deprecated); | ||
say : string; | ||
height : short; | ||
|
||
buffers:[Buffer]; | ||
} | ||
file_identifier "NOOB"; | ||
root_type FooBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
017023d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please state the result of the run - does the verifier complain?
Note that tables are not structs. A vector of tables is a vector of 4 byte offsets to individually placed tables. A table is aligned to 4 bytes (but can contain payload with padding and higher alignment). A byte vector in a table is stored as a 4 byte offset the vector. The vector itself would be 4 byte aligned due to the size prefix field of the vector, but otherwise only be required to align to 1 byte.
If you want to test large aligment, use a struct instead of table. A vector of structs will store the structs inline instead of as offsets, and the vectors first element should be aligned to the size of the struct.
017023d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something here. The low-level builder calls.