Skip to content

Conversation

@amykhuang
Copy link
Collaborator

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.

@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2025

@llvm/pr-subscribers-libc

Author: Amy Huang (amykhuang)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/144148.diff

1 Files Affected:

  • (modified) libc/src/string/string_utils.h (+1-2)
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>

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amykhuang amykhuang merged commit c42912b into llvm:main Jun 13, 2025
15 checks passed
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
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.
akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants