Ensure appropriate minimum alignment on flatbuffer tables
If you had a table whose fields all had alignments of <4 bytes, the
overall table still needed to have 4 byte alignment to account for the
various offsets included in every table.
Change-Id: I7c39c647d79dff80732f84c4e530319ee8f20c99
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/flatbuffers/static_flatbuffers.cc b/aos/flatbuffers/static_flatbuffers.cc
index 502e33e..7b42ef6 100644
--- a/aos/flatbuffers/static_flatbuffers.cc
+++ b/aos/flatbuffers/static_flatbuffers.cc
@@ -627,9 +627,9 @@
}
}
- const std::string alignment =
- absl::StrCat("static constexpr size_t kAlign = std::max<size_t>({",
- absl::StrJoin(alignments, ", "), "});\n");
+ const std::string alignment = absl::StrCat(
+ "static constexpr size_t kAlign = std::max<size_t>({kMinAlign, ",
+ absl::StrJoin(alignments, ", "), "});\n");
const std::string size =
absl::StrCat("static constexpr size_t kSize = ",
AlignCppString(offset_data_start_expression + " + " +