EncoreJiang / cpp-btree

Automatically exported from code.google.com/p/cpp-btree
Apache License 2.0
0 stars 0 forks source link

Many strict-aliasing warnings #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Using the library in my project. build it.

What is the expected output? What do you see instead?
Many strict-aliasing warnings issued at
reference btree_node::value(int i)
What version of the product are you using? On what operating system?
1.0.1,linux, gcc 4.5.1

Please provide any additional information below.
My solution:
Add a cast function:
template <typename To, typename From>
To reconst_cast(From& from) {
  return reinterpret_cast<To>(from);
}

template <typename Params>
class btree_node {
  ...
  reference value(int i) {
    return reconst_cast<reference>(fields_.values[i]);
  }
  const_reference value(int i) const {
    return reconst_cast<const_reference>(fields_.values[i]);  }

See thr attachment.

Original issue reported on code.google.com by chen3feng on 7 Apr 2013 at 4:05

Attachments: