[RFC] Throwing an exception with null pointers
Dave P.
dave287091 at gmail.com
Thu Apr 17 07:21:44 UTC 2025
On Thursday, 17 April 2025 at 05:31:48 UTC, Walter Bright wrote:
> On 4/16/2025 2:49 PM, Dave P. wrote:
>> [...]
> I've long since given up on memorizing the documentation of
> each parameter. Too many functions! I just google it, it just
> takes a sec.
It’s easier to goto-definition and see the annotations. Fancier
editors can even show it inline.
> [...]
> I don't see how a runtime detector can work better than a seg
> fault with stack trace.
The source of a null pointer can be very far from its eventual
dereference, especially when stored in a structure.
The nullability sanitizer also doesn’t kill your program by
default, it just logs when a null pointer is stored in a nonnull
variable. So you can see where the first non null store is made
and see how it eventually moves to when it is derefenced.
---
It’s funny though, when I first started using this kind of thing
it caught loads of bugs. But after years of use, I realized it
hadn’t caught any bugs in a long time. I had internalized the
rules.
More information about the Digitalmars-d
mailing list