3 ms·
> by defining NULL to be something else I bet that around 99% of C code in the real world assumes that NULL == 0. I'm sure that if it would be easy to make nul
by flohofwoe 4y ago
> by defining NULL to be something else
I bet that around 99% of C code in the real world assumes that NULL == 0. I'm sure that if it would be easy to make nullptr accesses trap in WASM browser runtimes without killing performance, the Emscripten team would have come up with a solution.
- josefx 4y ago> I bet that around 99% of C code in the real world assumes that NULL == 0. That is the correct assumption as 0 is interpreted as a null pointer constant when interpreted as a pointer. As far as I understand you have to do something like memset(ptr,0,sizeof(int*)) to bypass this conversion and get a pointer to the memory location 0 instead of a NULL pointer.
- saurik 4y agoYeah, but that memset is super common due to how people clear structs.