News for hackers. Stuff that matters.
Re:Null Pointer Dereferencing Causes Undefined Behavior by userbinator on Monday April 20, 2015 @07:54PM (#9411545)
> the standard places no restrictions on what compilers can do for such constructs.

But it does list some suggestions on what could happen, one of which is "behaving during translation or program execution in a documented manner characteristic of the environment", which is what most C programmers expect of the language. Violating this implicit assumption is what makes compilers user-hostile; choosing the worst possible behaviour, just because the standard does not define it, is never the right thing to do.

Related reading:

http://blog.metaobject.com/2014/04/cc-osmartass.html

http://thetrendythings.com/read/7057

http://blog.regehr.org/archives/1180

Re:Null Pointer Dereferencing Causes Undefined Behavior by _kst_ on Monday April 20, 2015 @08:14PM (#9411620)
That suggestion is pretty vague; the only way a compiler could violate it is by not documenting its behavior. The behavior itself can still be completely arbitrary.
Re:Null Pointer Dereferencing Causes Undefined Behavior by mpweiher on Tuesday April 21, 2015 @09:03AM (#9413711)
Well, before the first ANSI standard, ALL behavior was "undefined", and yet we got many working compilers and tons of working code.
Re:Null Pointer Dereferencing Causes Undefined Behavior by _kst_ on Tuesday April 21, 2015 @04:27PM (#9416824)
Before the first ANSI standard, we had the C Reference Manual in the back of K&R1. The definition was merely less rigorous (and that lack of rigor often led to complex nests of "#ifdef"s). If a compiler generated code that evaluated 2 + 2 and yielded a result of 5, we could confidently say that compiler had a bug.