3 ms·
Only if that memory page is unmapped, and only if the optimizer doesn't detect that it's a null pointer and start deleting verification code because derefing nu
by Measter 11mo ago
Only if that memory page is unmapped, and only if the optimizer doesn't detect that it's a null pointer and start deleting verification code because derefing null is UB, and UB is assumed to never happen.
- charlie90 11mo agoHow common is this in practice?
- adrianN 11mo agoCompilers regularly delete null pointer checks when they can see that the pointer is dereferenced.
- Smaug123 11mo ago(GCC controls this with `-fno-delete-null-pointer-checks` https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fdelete-null-pointer-checks https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#ind... )