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.
This commit is contained in:
Amy Huang
2025-06-13 13:07:39 -07:00
committed by GitHub
parent 1ded2c599f
commit c42912b8c9

View File

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