From 65cd686f1613075ea7fd55a76d92ad9545065eb4 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 20 May 2022 12:00:09 +0200 Subject: [PATCH] SuffixMatchTree: Fix compilation on old libstdc++ Move the < operator definition before the set one, so that old versions of libstdc++ do not mistakenly refuse to compile: ``` In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/map:60: /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_tree.h:452:7: error: static_assert failed due to requirement 'std::__is_invocable &, const SuffixMatchTree &, const SuffixMatchTree &>{}' "comparison object must be invocable with two arguments of key type" static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{}, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_set.h:133:17: note: in instantiation of template class 'std::_Rb_tree, SuffixMatchTree, std::_Identity >, std::less, std::allocator > >' requested here _Rep_type _M_t; // Red-black tree representing set. ^ ../../pdns/dnsname.hh:306:50: note: in instantiation of template class 'std::set, std::less, std::allocator > >' requested here mutable std::set> children; ^ ../../pdns/dnsname.hh:497:27: note: in instantiation of template class 'SuffixMatchTree' requested here SuffixMatchTree d_tree; ^ ``` Sseen with clang8 on Buster, but see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85965 --- pdns/dnsname.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index d0bc010d2e..f27b50c389 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -316,15 +316,15 @@ struct SuffixMatchTree } return *this; } + bool operator<(const SuffixMatchTree& rhs) const + { + return strcasecmp(d_name.c_str(), rhs.d_name.c_str()) < 0; + } std::string d_name; mutable std::set> children; mutable bool endNode; mutable T d_value; - bool operator<(const SuffixMatchTree& rhs) const - { - return strcasecmp(d_name.c_str(), rhs.d_name.c_str()) < 0; - } /* this structure is used to do a lookup without allocating and copying a string, using C++14's heterogeneous lookups in ordered -- 2.47.2