[libc-commits] [libc] [libc] fix behavior of strrchr(x, '\0') (PR #112620)

George Burgess IV via libc-commits libc-commits at lists.llvm.org
Wed Oct 30 10:48:22 PDT 2024


gburgessiv wrote:

So, better response:

> I thought the nice thing about ASSERT_EQ or in this case ASSERT_STREQ is that when the assertion fails, it tells you what was expected vs what was observed (i.e. NULL vs 'a') rather than expected true, saw false? I think that kind of behavior is nice to retain.

I tried to use `ASSERT_EQ`/`ASSERT_NE`, but `ASSERT_NE("foo", nullptr)` turns into an overload resolution error. I've updated my patch to allow `ASSERT_{EQ,NE}(foo, nullptr)`. Alternatively
- can `static_cast<const char *>()` around the nullptrs if that'd be preferred,
- or I can add a second overload if llvm-libc doesn't have conventions around whether `nullptr` constants should go in the LHS or RHS positions

https://github.com/llvm/llvm-project/pull/112620


More information about the libc-commits mailing list