mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-02 02:07:25 +00:00
[C++] Rare bad buffer content alignment if sizeof(T) != alignof(T) (#7520)
* [C++] Add a failing unit test for #7516 (Rare bad buffer content alignment if sizeof(T) != alignof(T)) * [C++] Fix final buffer alignment when using an array of structs * A struct can have an arbitrary size and therefore sizeof(struct) == alignof(struct) does not hold anymore as for value primitives. * This patch fixes this by introducing alignment parameters to various CreateVector*/StartVector calls. * Closes #7516
This commit is contained in:
parent
bfceebb7fb
commit
72aa85a759
10 changed files with 611 additions and 16 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "evolution_test.h"
|
||||
#include "alignment_test.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "flatbuffers/minireflect.h"
|
||||
|
|
@ -1416,6 +1417,8 @@ int FlatBufferTests(const std::string &tests_data_path) {
|
|||
|
||||
SizePrefixedTest();
|
||||
|
||||
AlignmentTest();
|
||||
|
||||
#ifndef FLATBUFFERS_NO_FILE_TESTS
|
||||
ParseAndGenerateTextTest(tests_data_path, false);
|
||||
ParseAndGenerateTextTest(tests_data_path, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue