[libc-commits] [PATCH] D83353: [libc] Add strchr implementation.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jul 10 11:16:46 PDT 2020


sivachandra accepted this revision.
sivachandra added inline comments.
This revision is now accepted and ready to land.


================
Comment at: libc/src/string/strchr.cpp:18
+char *LLVM_LIBC_ENTRYPOINT(strchr)(const char *src, int c) {
+  char *str = const_cast<char *>(src);
+  const unsigned char ch = c;
----------------
The comparison should be for two values with the same sign. So, this should be:

```
unsigned char *str = const_cast<unsigned char *>(reinterpret_cast<const unsigned char *>(src));
```

When returning, `reinterpret_cast` it back to `char *`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83353/new/

https://reviews.llvm.org/D83353





More information about the libc-commits mailing list