AvalancheBlockUpdate rely on the two lowers bits of a CBlockIndex* to be zero to work properly. While we know this is true, enforcing this is the case using a static assert is preferable.
- Group Reviewers
- rSTAGINGba12b8e01f69: [avalanche] Add some safety to AvalancheBlockUpdate using static asserts
rABCba12b8e01f69: [avalanche] Add some safety to AvalancheBlockUpdate using static asserts
|153 ↗||(On Diff #6419)|
See the build failure:
In file included from ../../src/avalanche.cpp:5:0: ../../src/avalanche.h:153:52: error: expected ‘,’ before ‘)’ token static_assert(alignof(CBlockIndex) >= 1 << BITS);
static_assert(statement, message) needs an error message
I don't think you're checking anything useful here.
If the arch does not support unaligned access, the static_assert is redundant with the compiler behavior.
If the address is forced unaligned (e.g. using packing), the static_assert will not detect it anyway, and your status and block index will get corrupted.
You can only check at runtime that pindexIn is aligned to a multiple of (1 << STATUS_BITS).