This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit acfbbcd7c6ebd0237e0c69100cf0354a7b21a7cc Author: Brian Neradt <brian.ner...@gmail.com> AuthorDate: Tue Mar 26 22:51:47 2024 -0500 Fix GCC 14.0.1 -std=c++20 build failures (#11189) * comparison of unsigned expression in ‘>= 0’ is always true lib/swoc/include/swoc/TextView.h: In instantiation of ‘uintmax_t swoc::_1_5_11::svto_radix(TextView&) [with int RADIX = 16; uintmax_t = long unsigned int]’: lib/swoc/include/swoc/TextView.h:1082:23: required from ‘uintmax_t swoc::_1_5_11::svto_radix(TextView&&) [with int N = 16; uintmax_t = long unsigned int]’ lib/swoc/include/swoc/TextView.h:1065:27: error: 1082 | return svto_radix<N>(src); lib/swoc/include/swoc/TextView.h:1065:27: error: | ~~~~~~~~~~~~~^~~~~ lib/swoc/src/bw_format.cc:928:28: required from here lib/swoc/include/swoc/TextView.h:1065:27: error: 928 | auto b = svto_radix<16>(span.clip_prefix(2).rebind<char const>()); lib/swoc/include/swoc/TextView.h:1065:27: error: | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/swoc/include/swoc/TextView.h:1065:27: error: comparison of unsigned expression in ‘>= 0’ is always true [-Werror=type-limits] 1065 | while (src.size() && (0 <= (v = swoc::svtoi_convert[uint8_t(*src)])) && v < RADIX) { | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors Second warning: src/tscore/HostLookup.cc: In member function ‘void CharIndex::Insert(std::string_view, HostBranch*)’: src/tscore/HostLookup.cc:304:12: error: ‘any_of’ is not a member of ‘std’ 304 | if (std::any_of(match_data.begin(), match_data.end(), [](unsigned char c) { return asciiToTable[c] == 255; })) { | ^~~~~~ src/tscore/HostLookup.cc: In member function ‘HostBranch* CharIndex::Lookup(std::string_view)’: src/tscore/HostLookup.cc:351:12: error: ‘any_of’ is not a member of ‘std’ 351 | if (std::any_of(match_data.begin(), match_data.end(), [](unsigned char c) { return asciiToTable[c] == 255; })) { | ^~~~~~ * ‘any_of’ is not a member of ‘std’ src/tscore/HostLookup.cc: In member function ‘void CharIndex::Insert(std::string_view, HostBranch*)’: src/tscore/HostLookup.cc:304:12: error: ‘any_of’ is not a member of ‘std’ 304 | if (std::any_of(match_data.begin(), match_data.end(), [](unsigned char c) { return asciiToTable[c] == 255; })) { | ^~~~~~ src/tscore/HostLookup.cc: In member function ‘HostBranch* CharIndex::Lookup(std::string_view)’: src/tscore/HostLookup.cc:351:12: error: ‘any_of’ is not a member of ‘std’ 351 | if (std::any_of(match_data.begin(), match_data.end(), [](unsigned char c) { return asciiToTable[c] == 255; })) { | ^~~~~~ * error: template-id not allowed for constructor in C++20 plugins/header_rewrite/matcher.h:71:23: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor] 71 | explicit Matchers<T>(const MatcherOps op) : Matcher(op), _data() {} | ^ plugins/header_rewrite/matcher.h:71:23: note: remove the ‘< >’ /home/bneradt/src/ts_asf_master_fix_std_20_build_failure/plugins/header_rewrite/matcher.h:222:38: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor] 222 | explicit Matchers<const sockaddr *>(const MatcherOps op) : Matcher(op) {} | ^ /home/bneradt/src/ts_asf_master_fix_std_20_build_failure/plugins/header_rewrite/matcher.h:222:38: note: remove the ‘< >’ (cherry picked from commit 6a9e39d6bb666a7849f5d414d230776dba543a02) --- lib/swoc/include/swoc/TextView.h | 2 +- plugins/header_rewrite/matcher.h | 4 ++-- src/tscore/HostLookup.cc | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/swoc/include/swoc/TextView.h b/lib/swoc/include/swoc/TextView.h index 9e914c8a63..3fecf0315b 100644 --- a/lib/swoc/include/swoc/TextView.h +++ b/lib/swoc/include/swoc/TextView.h @@ -1062,7 +1062,7 @@ svto_radix(TextView &src) { static constexpr auto OVERFLOW_LIMIT = MAX / RADIX; uintmax_t zret = 0; uintmax_t v; - while (src.size() && (0 <= (v = swoc::svtoi_convert[uint8_t(*src)])) && v < RADIX) { + while (src.size() && ((v = swoc::svtoi_convert[uint8_t(*src)]) < RADIX)) { // Tweaked for performance - need to check range after @a RADIX multiply. ++src; // Update view iff the character is parsed. if (zret <= OVERFLOW_LIMIT && v <= (MAX - (zret *= RADIX)) ) { diff --git a/plugins/header_rewrite/matcher.h b/plugins/header_rewrite/matcher.h index a40f2e6d13..fb56a29df6 100644 --- a/plugins/header_rewrite/matcher.h +++ b/plugins/header_rewrite/matcher.h @@ -79,7 +79,7 @@ protected: template <class T> class Matchers : public Matcher { public: - explicit Matchers<T>(const MatcherOps op) : Matcher(op), _data() {} + explicit Matchers(const MatcherOps op) : Matcher(op), _data() {} // Getters / setters const T & get() const @@ -209,7 +209,7 @@ private: template <> class Matchers<const sockaddr *> : public Matcher { public: - explicit Matchers<const sockaddr *>(const MatcherOps op) : Matcher(op) {} + explicit Matchers(const MatcherOps op) : Matcher(op) {} void set(const std::string &data) diff --git a/src/tscore/HostLookup.cc b/src/tscore/HostLookup.cc index ddb1ffe0a7..3480357839 100644 --- a/src/tscore/HostLookup.cc +++ b/src/tscore/HostLookup.cc @@ -28,6 +28,7 @@ * ****************************************************************************/ +#include <algorithm> #include <string_view> #include <array> #include <memory>