[libc-commits] [libc] c891ef6 - [libc] Fix strcspn

Alex Brachet via libc-commits libc-commits at lists.llvm.org
Wed Mar 1 10:58:01 PST 2023


Author: Alex Brachet
Date: 2023-03-01T18:57:53Z
New Revision: c891ef6ca01464cec9d1a53f9be0d0332999101f

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

LOG: [libc] Fix strcspn

Differential Revision: https://reviews.llvm.org/D144995

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 90579c2b22a83..d42f11384b1f2 100644
--- a/libc/src/string/string_utils.h
+++ b/libc/src/string/string_utils.h
@@ -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;
 }


        


More information about the libc-commits mailing list