This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git

commit 7af411e3233ac2262565a28935d1fa382cfd53ab
Author: Brian Neradt <brian.ner...@gmail.com>
AuthorDate: Mon Apr 15 16:41:28 2024 +0000

    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 ‘< >’
---
 code/include/swoc/TextView.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/code/include/swoc/TextView.h b/code/include/swoc/TextView.h
index 9e914c8..3fecf03 100644
--- a/code/include/swoc/TextView.h
+++ b/code/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)) ) {

Reply via email to