[RFC] Throwing an exception with null pointers
Derek Fawcus
dfawcus+dlang at employees.org
Wed Apr 16 13:41:16 UTC 2025
On Wednesday, 16 April 2025 at 08:49:39 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> On 16/04/2025 8:18 PM, Atila Neves wrote:
>
>> * Use a nullable/option type.
>
> While valid to box pointers, we would then need to disallow
> them in business logic functions.
I'm not sure what you have in mind, what I have in mind is
something like this:
https://discourse.llvm.org/t/rfc-nullability-qualifiers/35672
https://clang.llvm.org/docs/analyzer/developer-docs/nullability.html
The checks here are performed in a distinct SA tool, not in the
main compiler. However it catches the main erroneous cases -
first two listed checks of second link:
> If a pointer p has a nullable annotation and no explicit null
> check or assert, we should warn in the following cases:
>
>- p gets implicitly converted into nonnull pointer, for
>example, we are passing it to a function that takes a nonnull
>parameter.
>
>- p gets dereferenced
Given how individual variable / fields have to be annotated, it
probably does not need complete DFA, but only function local
analysis for loads/stores/compares.
More information about the Digitalmars-d
mailing list