3 ms·
> Doesn't null-pointer-dereference always crash the application? No. It's undefined behaviour, it may do anything or nothing. > Is it only an undefined-behavi
by lmm 1y ago
> Doesn't null-pointer-dereference always crash the application?
No. It's undefined behaviour, it may do anything or nothing.
> Is it only an undefined-behavior because program-must-crash is not the explicitly required by these languages' specs?
I don't understand the question here. It's undefined behaviour because the spec says it's undefined behaviour, which is some combination of because treating it as impossible allows many optimisation opportunities and because of historical accidents.
- iambvk 1y ago> No. It's undefined behaviour, it may do anything or nothing. This is clearly nonsense.
- quotemstr 1y agoIt is not nonsense: see https://lwn.net/Articles/575563/ https://lwn.net/Articles/575563/ Compilers are allowed to assume undefined behavior doesn't happen, and dereferencing an invalid pointer is undefined behavior. You don't have to like it, but that's how it is.
- lmm 1y ago> This is clearly nonsense. It is indeed. Unfortunately it's also the C language standard.