On Saturday, 11 January 2025 at 02:01:50 UTC, Richard (Rikki) Andrew Cattermole wrote:
>On 11/01/2025 2:43 PM, Walter Bright wrote:
>Curiously, compiling it with gcc -O3
does not detect it. ImportC doesn't detect it, either, a choice made because some C code uses such a construct as a way to drop into the debugger.
Yeah you didn't turn the warning on.
[...snip...]
>flags: -Wnull-dereference -O
[...snip...]
>Ergo, gdc also warns about this with the same flags.
$ gdc nullptrdect.d -O -Wnull-dereference
nullptrdect.d: In function ‘D main’:
nullptrdect.d:3:10: warning: null pointer dereference [-Wnull-dereference]
3 | *ptr = 3;
| ^