News for hackers. Stuff that matters.
Re:Null Pointer Dereferencing Causes Undefined Behavior by jwatte on Monday April 20, 2015 @10:51PM (#9412022)
The post hinges on the faulty assumption that calculating the address of an lvalue "evaluates" that lvalue. This is not so.

Any compiler that generates anything other than an add instruction (or lea or similar) is broken, for rather unsubtle reasons.

Or to put it another way: dereferencing a null pointer may be undefined, but arithmetic on any pointer (including null) is well defined, and the code in question is arithmetic, not dereference.

And, yet another broken blog post will make the rounds on the internet every three years and confuse even more people. It's sad.

Re:Null Pointer Dereferencing Causes Undefined Behavior by pcwalton on Monday April 20, 2015 @11:43PM (#9412173)
The post cites the spec. The C standard clearly seems to state that & must reference "an object", and NULL does not reference an object. A "pointer to any object" is distinguished from a null pointer.

Do you have links stating otherwise?

Re:Null Pointer Dereferencing Causes Undefined Behavior by Gibbon1 on Tuesday April 21, 2015 @01:42AM (#9412449)
An of course plain C does not have 'objects' and a _lot_ of architectures have stuff mapped at address 0x0
Re:Null Pointer Dereferencing Causes Undefined Behavior by nullc on Tuesday April 21, 2015 @04:59AM (#9412906)
You may be mistaking C for a fancy macro assembler.

It's not-- It's a high level language, even though a fairly low level looking one. The obligation of the language is to behave as the spec says, and there may not be a close mapping between your program and what runs on the machine, though there often is.

An "Object" is a concept defined and used extensively in the language specification; "a region of data storage in the execution environment,".

Re:Null Pointer Dereferencing Causes Undefined Behavior by rcfox on Tuesday April 21, 2015 @01:58AM (#9412481)
While C is not an "object-oriented" language, it does have a concept of an object: http://port70.net/~nsz/c/c99/n1256.html#3.14p1
Re:Null Pointer Dereferencing Causes Undefined Behavior by aidenn0 on Tuesday April 21, 2015 @01:53AM (#9412468)
C absolutely does have objects.