After inlining, GCC's VRP sees mutable_child() reaching a leaf-root
node whose static type only bounds values[], not children[], and fires
even though the if(!leaf()) guard prevents it at runtime:
btree.h:522: warning: array subscript [33, 287] is outside array
bounds of 'struct M[32]' [-Warray-bounds]
Decay children[] to a raw pointer in child()/mutable_child() so GCC
has no array bounds to check.
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
const_reference value(int i) const { return params_type::element(slot(i)); }
// Getters/setter for the child at position i in the node.
- btree_node* child(int i) const { return *(GetField<&internal_fields::children>() + i); }
- btree_node*& mutable_child(int i) { return *(GetField<&internal_fields::children>() + i); }
+ btree_node* child(int i) const {
+ auto* p = GetField<&internal_fields::children>();
+ return p[i];
+ }
+ btree_node*& mutable_child(int i) {
+ auto* p = GetField<&internal_fields::children>();
+ return p[i];
+ }
void clear_child(int i) {
#ifndef NDEBUG
memset(&mutable_child(i), 0, sizeof(btree_node*));