]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
SuffixMatchTree: Fix compilation on old libstdc++
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 20 May 2022 10:00:09 +0000 (12:00 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 1 Jun 2022 09:32:36 +0000 (11:32 +0200)
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<std::less<void> &, const SuffixMatchTree<bool> &, const SuffixMatchTree<bool> &>{}' "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<bool>, SuffixMatchTree<bool>, std::_Identity<SuffixMatchTree<bool> >, std::less<void>, std::allocator<SuffixMatchTree<bool> > >' requested here
      _Rep_type _M_t;  // Red-black tree representing set.
                ^
../../pdns/dnsname.hh:306:50: note: in instantiation of template class 'std::set<SuffixMatchTree<bool>, std::less<void>, std::allocator<SuffixMatchTree<bool> > >' requested here
  mutable std::set<SuffixMatchTree, std::less<>> children;
                                                 ^
../../pdns/dnsname.hh:497:27: note: in instantiation of template class 'SuffixMatchTree<bool>' requested here
    SuffixMatchTree<bool> d_tree;
                          ^
```
Sseen with clang8 on Buster, but see also
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85965

pdns/dnsname.hh

index d0bc010d2e3fcb73c56683730f86cb669859a7bd..f27b50c38957e4cfc834ddb6e79f3209fb0527c2 100644 (file)
@@ -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<SuffixMatchTree, std::less<>> 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