Mail Archives: djgpp/2013/08/06/09:09:42
> > NULL's actual value is required to be zero, from the program's point
> > of view.
>
> If it's from the program's point of view, then it's not it's actual
> value. It's its semantic representation.
Now you're being overly pedantic. NULL is zero, the standard says so.
How that relates to hardware is irrelevent, as it should never be
dereferenced.
> The point is on *any* memory system The actual value used for
> NULL needn't be zero.
No, the standard says the actual value used for NULL needs to be zero.
> So, I take it you also disagree with the C compiler automatically
> initializing unitialized variables.
The standard says that they're initialized, so I agree with the
compiler initializing them.
> I'll also take it you dislike 'void' and 'void*' since those also
> prevent users from coding making certain coding mistakes with pointers.
I like void because it prevents certain coding mistakes.
> I.e., I don't see why you'd like the just mentioned "safety"
> features of C, but you wouldn't like another change that would
> prevent similar novice style coding mistakes...
Defererencing NULL is something the standard says you *shouldn't* do,
so I like making sure you *shouldn't* do it.
> > IMHO if a pointer points to *anything* that "works", it's
> > a bad choice for NULL.
>
> Even if NULL still functions correctly as NULL?
Sure. NULL is a pointer that doesn't point to anything. I like
systems that make sure it *really* doesn't point to anything.
> NULL can still be compared to.
That's its purpose.
> It just now functions as an empty string for functions expecting
> strings,
This is a bad idea.
> if they don't explicitly check for NULL.
If they don't check, either they're broken, the function was called
wrong, or the program crashes.
If the program is broken, it should break *hard* so you can (1) tell
that it's broken, and (2) fix it easily.
- Raw text -