when attempting to perform pointer arithmetic on a null pointer dcc complains that its dereferencing a null pointer. valgrind and clang with ub and address sanitisers dont complain about this issue
mre:
int main(void) {
(void)((int *)0+0);
return 0;
}
Runtime error: accessing a value via a NULL pointer
dcc explanation: You are using a pointer which is NULL
A common error is accessing *p when p == NULL.
Execution stopped in main() in test.c at line 2:
int main(void) {
--> (void)((int *)0+0);
return 0;
}
Don't understand? Get AI-generated help by running: dcc-help, or interactive he
lp with dcc-sidekick
even weirder, when the pointer is initialised to anything other than 0, this error doesnt occur even though its undefined behaviour to initialise to an aitrary non zero integer and its also still ub to perform pointer arithmetic on these values.
and even moree weirder, some types such as char * and void * dont trigger this error but it seems like any other type does