Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The literal `0` is guaranteed to be the null pointer value when used as a pointer, so by definition

    NULL == (void*)0.
But given

    void *p = 0; 
    intptr_t i = 0;
it is not guaranteed that `memcmp(&i, &p, sizeof(p)) == 0`.


> it is not guaranteed that `memcmp(&i, &p, sizeof(p)) == 0`.

Even less intuitively, it is not guaranteed that `(void*)i == p` since `i` is not an integer constant expression, even if the value is known to be 0.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: