News for hackers. Stuff that matters.
Re:The ugliest C feature: <tgmath.h> by ootachi on Monday December 26, 2011 @12:04PM (#3393279)
It's even simpler. A lot of legacy code out there uses "0" (not NULL or even (void ∗)0, just 0) in place of NULL. So it's very important for backwards compatibility that "test ? (double ∗)x : 0" or "test ? 0 : (int ∗)x" return double ∗ or int ∗, respectively.

I'm not sure why the definition of a null pointer has to be so liberal, but I suspect there's a backwards compatibility constraint in there.

Re:The ugliest C feature: <tgmath.h> by jimbobimbo on Monday December 26, 2011 @03:39PM (#3393881)
I'm not sure if this covers C++ only, but here's what Stroustrup has to say:

"In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0."

Re:The ugliest C feature: <tgmath.h> by kelnos on Monday December 26, 2011 @05:08PM (#3394061)
That definition is indeed C++-only.
Re:The ugliest C feature: <tgmath.h> by kzrdude on Monday December 26, 2011 @06:50PM (#3394246)
Not sure in which sense it is C++ only. 0 is a null pointer constant in C.
Re:The ugliest C feature: <tgmath.h> by kelnos on Sunday January 08, 2012 @07:30AM (#3439427)
My mistake. I could have sworn that only C++ defined 0 to be equivalent to a null pointer. I guess my confusion stemmed from the fact that the NULL preprocessor macro in C++ is actually defined to be just "0" (or a magical-seeming "__null" in recent versions of g++), whereas in any modern C implementation I've seen, it's "((void *)0)".

Though there are cases in which passing an unadorned "0" as a null pointer can be wrong; there's a null-terminated varargs function example here:

http://c-faq.com/null/null2.html