[OT] OT: Null checks.

Timon Gehr timon.gehr at gmx.ch
Sun May 4 03:55:01 UTC 2025


On 5/4/25 03:36, Walter Bright wrote:
> 
> The D version with the small DMD compiler:
> 
> ```
> int main()
> {
>      int* p = null;
>      ref int q = *p;
>      return q;
> }
> ```
> ```
> dmd x.d -O
> x.d(6): Error: null dereference in function _Dmain
> ```

I don't understand why you think demonstrating something with your own 
backend disproves a point about the world at large excluding your own 
backend. You did also run a test with GCC for the C version, but UB is 
simply not reliable.

You can go to d.godbolt.org, select "ldc latest CI", pass arguments "-O" 
and confirm for yourself that `_Dmain` is simply this:


```
_Dmain:
         ret
```

This is in accordance with the C standard.


More information about the Digitalmars-d mailing list