[libc-commits] [libc] c42912b - Fix string_length function so that it always returns. (#144148)

via libc-commits libc-commits at lists.llvm.org
Fri Jun 13 13:07:42 PDT 2025


Author: Amy Huang
Date: 2025-06-13T13:07:39-07:00
New Revision: c42912b8c96ff1130437e47c163aeb5c1191fe5d

URL: https://github.com/llvm/llvm-project/commit/c42912b8c96ff1130437e47c163aeb5c1191fe5d
DIFF: https://github.com/llvm/llvm-project/commit/c42912b8c96ff1130437e47c163aeb5c1191fe5d.diff

LOG: Fix string_length function so that it always returns. (#144148)

Previously setting LIBC_COPT_STRING_UNSAFE_WIDE_READ would cause a build
error because there is a path in the ifdef that doesn't return anything.

Added: 
    

Modified: 
    libc/src/string/string_utils.h

Removed: 
    


################################################################################
diff  --git a/libc/src/string/string_utils.h b/libc/src/string/string_utils.h
index dcbfc7584a30e..4f56263fce8ec 100644
--- a/libc/src/string/string_utils.h
+++ b/libc/src/string/string_utils.h
@@ -90,12 +90,11 @@ template <typename T> LIBC_INLINE size_t string_length(const T *src) {
   // string a block at a time.
   if constexpr (cpp::is_same_v<T, char>)
     return string_length_wide_read<unsigned int>(src);
-#else
+#endif
   size_t length;
   for (length = 0; *src; ++src, ++length)
     ;
   return length;
-#endif
 }
 
 template <typename Word>


        


More information about the libc-commits mailing list