Fun thought experiment: Consider how to make a language with null pointers memory-safe in LLVM. Null dereference is UB, so you have to make sure it never happens. I think you just have to add explicit null checks everywhere before you dereference them…
-
-
Also -fno-delete-null-pointer-checks prevents the compiler from removing code like 'if(this == nullptr) { ... } '
- 3 more replies
New conversation -
-
Oh right; I wonder why they didn’t just list the things that won’t create UB and call that the C standard. It’d fit on a single sheet of paper.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
And I believe there is nothing that says the bits of a “null pointer” are zero
-
Pointer to member bit representation of NULL was -1u on at least one major C++ compiler. Fun stuff to wrap your brain around.
End of conversation
New conversation -
-
-
C standard also says that NULL need not be 0x0 (just that an integer with value 0, when cast into (void *), turns into a NULL pointer).
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.