From 7ae702a49f36eff7a8b37ba451d80fb43e7da339 Mon Sep 17 00:00:00 2001 From: Davis King Date: Thu, 27 Dec 2012 15:56:56 -0500 Subject: [PATCH] Changed how murmur hash was used in find_max_factor_graph_nmplp to avoid a violation of the strict aliasing rule. This fixes a bug which caused find_max_factor_graph_nmplp() to not work properly on some compilers. --- dlib/optimization/find_max_factor_graph_nmplp.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dlib/optimization/find_max_factor_graph_nmplp.h b/dlib/optimization/find_max_factor_graph_nmplp.h index c78ff44f4..f9e0cc278 100644 --- a/dlib/optimization/find_max_factor_graph_nmplp.h +++ b/dlib/optimization/find_max_factor_graph_nmplp.h @@ -40,8 +40,7 @@ namespace dlib - #(*this)(a,b) == value !*/ { - const unsigned long block[2] = {a,b}; - const uint32 h = murmur_hash3(&block[0], sizeof(block))%(data.size()-scan_dist); + const uint32 h = murmur_hash3_2(a,b)%(data.size()-scan_dist); const unsigned long empty_bucket = std::numeric_limits::max(); @@ -85,8 +84,7 @@ namespace dlib DLIB_ASSERT(a != b, "An invalid map_problem was given to find_max_factor_graph_nmplp()." << "\nNode " << a << " is listed as being a neighbor with itself, which is illegal."); - const unsigned long block[2] = {a,b}; - uint32 h = murmur_hash3(&block[0], sizeof(block))%(data.size()-scan_dist); + uint32 h = murmur_hash3_2(a,b)%(data.size()-scan_dist); for (unsigned long i = 0; i < scan_dist; ++i)