From 34b13fc1f66c6e3a397cafa3490e6f30989f1b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Mon, 12 Feb 2024 18:30:17 +0100 Subject: [PATCH] Fix 'transposition growth' computation for older compilers The issue is probably due to some shenanigans with float-versus-double or converting size_t to double including some rounding up. Either way, it may introduce undefined behaviour or be interpreted multiple ways. This leads GCC 10 to unexpectedly abort repeated transposition. --- src/adiar/internal/algorithms/quantify.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/adiar/internal/algorithms/quantify.h b/src/adiar/internal/algorithms/quantify.h index ad914b9ff..83a1b76da 100644 --- a/src/adiar/internal/algorithms/quantify.h +++ b/src/adiar/internal/algorithms/quantify.h @@ -908,11 +908,11 @@ namespace adiar::internal const size_t dd_size = dd.size(); // Do Partial Quantification as long as... - // 1. ... it stays smaller than 1+epsilon% of the input size. - const size_t transposition__size_threshold = static_cast( - std::min(std::numeric_limits::max(), - ep.template get() - * static_cast(dd_size))); + // 1. ... it stays smaller than 1+epsilon of the input size. + const size_t transposition__size_threshold = + (std::min(static_cast(std::numeric_limits::max() / 2u), + static_cast(ep.template get()) + * static_cast(dd_size))); // 2. ... it has not run more than the maximum number of iterations. const size_t transposition__max_iterations =