From 82ef138385399bb3de323885e71f3c7a23d13313 Mon Sep 17 00:00:00 2001 From: spreadsort Date: Thu, 20 Apr 2023 19:09:34 -0400 Subject: [PATCH] Fix overflow issue with signed subtraction in float_sort Also fix a problem with windows running tune.pl --- include/boost/sort/spreadsort/detail/float_sort.hpp | 6 +++--- tune.pl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/sort/spreadsort/detail/float_sort.hpp b/include/boost/sort/spreadsort/detail/float_sort.hpp index 8682afd..2fb903f 100644 --- a/include/boost/sort/spreadsort/detail/float_sort.hpp +++ b/include/boost/sort/spreadsort/detail/float_sort.hpp @@ -410,7 +410,7 @@ namespace spreadsort { max, min)) return; unsigned log_divisor = get_log_divisor( - last - first, rough_log_2_size(Size_type(max - min))); + last - first, rough_log_2_size(Size_type(max/2 - min/2)) + 1); Div_type div_min = min >> log_divisor; Div_type div_max = max >> log_divisor; unsigned bin_count = unsigned(div_max - div_min) + 1; @@ -507,7 +507,7 @@ namespace spreadsort { if (is_sorted_or_find_extremes(first, last, max, min, rshift)) return; unsigned log_divisor = get_log_divisor( - last - first, rough_log_2_size(Size_type(max - min))); + last - first, rough_log_2_size(Size_type(max/2 - min/2)) + 1); Div_type div_min = min >> log_divisor; Div_type div_max = max >> log_divisor; unsigned bin_count = unsigned(div_max - div_min) + 1; @@ -605,7 +605,7 @@ namespace spreadsort { if (is_sorted_or_find_extremes(first, last, max, min, rshift, comp)) return; unsigned log_divisor = get_log_divisor( - last - first, rough_log_2_size(Size_type(max - min))); + last - first, rough_log_2_size(Size_type(max/2 - min/2)) + 1); Div_type div_min = min >> log_divisor; Div_type div_max = max >> log_divisor; unsigned bin_count = unsigned(div_max - div_min) + 1; diff --git a/tune.pl b/tune.pl index 598f1a9..4f83ce7 100755 --- a/tune.pl +++ b/tune.pl @@ -19,7 +19,7 @@ $realtimes = 0; $verifycorrect = 0; $verbose = 0; $exename = "spreadsort"; -$makename = "../../b2 \-\-tune"; +$makename = "b2 \-\-tune"; $all = ""; $iter_count = 1; $debug = 0;