[libc-commits] [libc] [libc] Expand usage of libc null checks. (PR #116262)
Aly ElAshram via libc-commits
libc-commits at lists.llvm.org
Fri Feb 7 16:20:16 PST 2025
================
@@ -17,6 +18,8 @@ namespace LIBC_NAMESPACE_DECL {
// TODO: Look at performance benefits of comparing words.
LLVM_LIBC_FUNCTION(void *, memchr, (const void *src, int c, size_t n)) {
+ const unsigned char *src_cpy = (const unsigned char *)src;
+ LIBC_CRASH_ON_NULLPTR(src_cpy);
----------------
AlyElashram wrote:
@nickdesaulniers I do think that the casting is ugly , however passing a void pointer to the macro would automatically throw an error by itself , whether the pointer is null or no.
My intention when casting was to maintain nullness/constness while still being able to use the trap function.
Not sure what the next step here should be. What do you guys think?
https://github.com/llvm/llvm-project/pull/116262
More information about the libc-commits
mailing list