Commit 0b82d5ea authored by Davis King's avatar Davis King

A minor change to avoid warnings about violation of string aliasing rules.

parent 371e3f39
...@@ -838,7 +838,12 @@ namespace ...@@ -838,7 +838,12 @@ namespace
value_type factor_value(unsigned long idx) const value_type factor_value(unsigned long idx) const
{ {
return ((double)murmur_hash3(&idx, sizeof(idx), seed) - std::numeric_limits<uint32>::max()/2.0)/1000.0; // Copy idx into a char buffer to avoid warnings about violation of strict aliasing
// rules when murmur_hash3() gets inlined into this function.
char buf[sizeof(idx)];
memcpy(buf,&idx,sizeof(idx));
// now hash the buffer rather than idx.
return ((double)murmur_hash3(buf, sizeof(buf), seed) - std::numeric_limits<uint32>::max()/2.0)/1000.0;
} }
value_type factor_value_disagreement(unsigned long idx1, unsigned long idx2) const value_type factor_value_disagreement(unsigned long idx1, unsigned long idx2) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment