[libc] Fix strcspn
authorAlex Brachet <abrachet@google.com>
Wed, 1 Mar 2023 18:57:07 +0000 (18:57 +0000)
committerAlex Brachet <abrachet@google.com>
Wed, 1 Mar 2023 18:57:53 +0000 (18:57 +0000)
Differential Revision: https://reviews.llvm.org/D144995

libc/src/string/string_utils.h

index 90579c2b22a83201e1bd82569023daefc2d40bc8..d42f11384b1f26ab77655aa8e1dff4359cfd88da 100644 (file)
@@ -166,8 +166,9 @@ LIBC_INLINE size_t complementary_span(const char *src, const char *segment) {
   cpp::bitset<256> bitset;
 
   for (; *segment; ++segment)
-    bitset.set(*segment);
-  for (; *src && !bitset.test(*src); ++src)
+    bitset.set(*reinterpret_cast<const unsigned char *>(segment));
+  for (; *src && !bitset.test(*reinterpret_cast<const unsigned char *>(src));
+       ++src)
     ;
   return src - initial;
 }