[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:
Denis Blank
2022-09-21 20:05:05 +02:00
committed by GitHub
parent bfceebb7fb
commit 72aa85a759
10 changed files with 611 additions and 16 deletions

12
tests/alignment_test.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef TESTS_ALIGNMENT_TEST_H
#define TESTS_ALIGNMENT_TEST_H
namespace flatbuffers {
namespace tests {
void AlignmentTest();
} // namespace tests
} // namespace flatbuffers
#endif