Adds runtime alignment assertions, see #3267
This commit is contained in:
committed by
Patrick Niklaus
parent
7dea7476f1
commit
559c88b36d
@@ -106,6 +106,7 @@ struct DataLayout
|
||||
|
||||
template <typename T> inline void SetBlockSize(BlockID bid, uint64_t entries)
|
||||
{
|
||||
static_assert(sizeof(T) % alignof(T) == 0, "aligned T* can't be used as an array pointer");
|
||||
num_entries[bid] = entries;
|
||||
entry_size[bid] = sizeof(T);
|
||||
entry_align[bid] = alignof(T);
|
||||
|
||||
@@ -373,7 +373,9 @@ class StaticRTree
|
||||
{
|
||||
m_leaves_region.open(leaf_file);
|
||||
std::size_t num_leaves = m_leaves_region.size() / sizeof(LeafNode);
|
||||
m_leaves.reset(reinterpret_cast<const LeafNode *>(m_leaves_region.data()), num_leaves);
|
||||
auto data_ptr = m_leaves_region.data();
|
||||
BOOST_ASSERT(reinterpret_cast<uintptr_t>(data_ptr) % alignof(LeafNode) == 0);
|
||||
m_leaves.reset(reinterpret_cast<const LeafNode *>(data_ptr), num_leaves);
|
||||
}
|
||||
catch (const std::exception &exc)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user