Reply to post:

Are you writing code for ambient computing? No? Don't even know? Ch-uh. Google's 'write once, run anywhere' Flutter is all over it

karlkarl Silver badge

If you have a NULL pointer o a struct and you access something on that struct, you believe the program will crash? That is good; it shows you that your code is broke and needs fixing.

It seems though that that isn't a part of the language standard to deterministically crash; it is simply undefined behavior, it could email a bunch of porn to your boss instead.

Why it seems to always crash on a modern OS is that that segment of memory is mprotect()'ed on standard operating systems (or VirtualProtect()ed if on Win32).

MSDOS with Watcom C didn't crash as far as I know when accessing NULL. It wasnt until DJGPP (GCC based C compiler) that a very early mprotect was implemented (and required virtual memory hardware).

So yes... the ONE thing that I rely so much on; is in theory undefined behavior.. Goddam C, why do I love you so much?

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon


Biting the hand that feeds IT © 1998–2021