[RFC] Throwing an exception with null pointers
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Wed Apr 16 22:56:33 UTC 2025
On 17/04/2025 10:50 AM, Derek Fawcus wrote:
> On Wednesday, 16 April 2025 at 21:12:08 UTC, Walter Bright wrote:
>> I'm curious - how does one traverse a binary tree with non-null
>> pointers? How does one create a circular data structure with non-null
>> pointers?
>
> One has nullable and nonnull pointers. One uses the former for the
> circular data structures.
>
> Now the current ugly bit with clang is this:
>
> ```C
> int foo(int * arg1, int * NULL_UNSPECIFIED arg2, int * NULLABLE arg3) {
>
> if (arg3 != 0)
> ptr = arg3;
>
> return a;
> }
> ```
>
> ```
> $ clang-14 -Wall -Wnullable-to-nonnull-conversion -c ttt.c
> ttt.c:36:9: warning: implicit conversion from nullable pointer 'int *
> _Nullable' to non-nullable pointer type 'int * _Nonnull' [-Wnullable-to-
> nonnull-conversion]
> ptr = arg3;
> ^
> ```
>
> i.e. there is no DFA, and one still has to cast the value in the
> assignment. So the clang support could stand some improvement.
I've been implementing this specific thing in my fast DFA implementation
recently.
Truthiness is needed for it to work.
However you can still be using DFA without supporting truthiness of
variables.
DFA is a very large subject domain.
More information about the Digitalmars-d
mailing list