On Mon, Nov 14, 2005 at 11:56:16PM +0100, Gabriel Dos Reis wrote: > "Michael N. Moran" <[EMAIL PROTECTED]> writes: > SEGFAULT is not a behaviour defined by the language. It is *just* one > form of undefined behaviour. If you execute that function, it might > reformat your harddrive and that woud be fine -- though I know of no > compiler that does that on purpose. But, the point is that your > program in erring in the outer space. > > | // dereference: access to object > | // If a is null, then SEGFAULT > | *a = 0; > > Again, that may or may not happen.
Some operating systems load a page of zeroes at address zero, so the dereference of a null pointer has no visible effect; a different form of undefined behavior. DYNIX/ptx did that by default, and I think that HP-UX does it. I much prefer a segfault. Janis