Browse Source

Fix "Dereferencing type-punned pointer will break strict aliasing rules..."

master
Vitaliy Filippov 10 months ago
parent
commit
5dc108754a
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      btree.h

+ 4
- 2
btree.h View File

@@ -554,10 +554,12 @@ class btree_node {
return params_type::key(fields_.values[i]);
}
reference value(int i) {
return reinterpret_cast<reference>(fields_.values[i]);
mutable_value_type *ptr = (mutable_value_type*)&fields_.values[i];
return reinterpret_cast<reference>(*ptr);
}
const_reference value(int i) const {
return reinterpret_cast<const_reference>(fields_.values[i]);
value_type *ptr = (value_type*)&fields_.values[i];
return reinterpret_cast<const_reference>(*ptr);
}
mutable_value_type* mutable_value(int i) {
return &fields_.values[i];


Loading…
Cancel
Save