[libc-commits] [PATCH] D140350: [libc][NFC] make atoi undefined cases match std
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon Dec 19 15:56:06 PST 2022
sivachandra accepted this revision.
sivachandra added inline comments.
This revision is now accepted and ready to land.
================
Comment at: libc/test/src/stdlib/AtoiTest.h:65
+ // rely on this behavior.
+ if constexpr (sizeof(ReturnT) < sizeof(long)) {
+ const char *bigger_than_biggest_int = "2147483649";
----------------
Nit: Make this conditional more explicit:
```
cpp::is_same_v<ReturnT, int> && sizeof(ReturnT) < sizeof(long)
```
================
Comment at: libc/test/src/stdlib/AtoiTest.h:66
+ if constexpr (sizeof(ReturnT) < sizeof(long)) {
+ const char *bigger_than_biggest_int = "2147483649";
+ ASSERT_EQ(func(bigger_than_biggest_int),
----------------
Nit: I think this assume `int` to be 4 bytes wide so add: `static_assert(sizeof(int) == 4)`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140350/new/
https://reviews.llvm.org/D140350
More information about the libc-commits
mailing list