[OT] OT: Null checks.
Derek Fawcus
dfawcus+dlang at employees.org
Sun May 4 10:24:22 UTC 2025
On Sunday, 4 May 2025 at 04:49:48 UTC, Timon Gehr wrote:
>
> My understanding is that null pointer dereference being UB is a
> widespread assumption in the LLVM and GCC optimizers. Simply
> "disabling the behavior" is not practical.
I recently read somewhere, (not sure if it was in these forums,
Hacker News, or Lobsters), that recent versions of LLVM have now
gained the ability to express that some forms of pointer will not
experience that behaviour.
i.e. something in the syntax (text form, and presumably bitcode)
allows one to indicate that dereference of a NULL pointer is not
to be viewed as undefined behaviour, and so it most not optimise
on the assumption that it is.
I assume that means a attempt to deref a NULL reference will then
end up being passed to the actual CPU in terms of code generated.
I suspect this may only be the most recent version, possibly the
pre-release development HEAD. I have no idea about any
equivalent in the GCC middle and back ends.
More information about the Digitalmars-d
mailing list