[libc-commits] [PATCH] D136802: [libc] add locale free strcoll

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Oct 26 22:01:25 PDT 2022


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


================
Comment at: libc/src/string/strcoll.cpp:19
+    ;
+  return *reinterpret_cast<const unsigned char *>(left) -
+         *reinterpret_cast<const unsigned char *>(right);
----------------
I think this is the same implementation as `strcmp`, but to avoid all type conversion/promotion confusions, we should cast the de-referenced value to `int`:

```
int(*reinterpret_cast<const unsigned char *>(left))
```


================
Comment at: libc/test/src/string/strcoll_test.cpp:22
+  result = __llvm_libc::strcoll(s2, s1);
+  ASSERT_EQ(result, 0);
+}
----------------
For completeness, you should add `ASSERT_GT` and `ASSERT_LT` tests also.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136802



More information about the libc-commits mailing list