From 92727ff3516c773b2e32249c8f3782f68f8a7cc4 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 18 May 2017 18:38:23 +1000 Subject: [PATCH] algo/sort: work around gcc lamba param aliasing bug --- algo/sort.ipp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/algo/sort.ipp b/algo/sort.ipp index d4b9df4b..e2cbd811 100644 --- a/algo/sort.ipp +++ b/algo/sort.ipp @@ -98,9 +98,17 @@ cruft::util::sort::soa (RandomIt key_first, std::sort (std::begin (indices), std::end (indices), - [&] (const auto &a, const auto &b) + [&] (const auto &cruft_util_sort_soa_a, const auto &cruft_util_sort_soa_b) { - return comp (key_first[a], key_first[b]); + // GCC: we use the ridiculous parameter names to avoid a name aliasing + // bug/warning under gcc 6.3.0; if the client passes a comparator + // lambda that uses the same parameter names then a warning will be + // generated. given 'a' and 'b' aren't unlikely names we try to avoid + // them here. + return comp ( + key_first[cruft_util_sort_soa_a], + key_first[cruft_util_sort_soa_b] + ); }); // convert from a sorted list of pointers to a mapping of pointers to