Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
[...]Yes, I meant null pointer constants. I didn't badly confuse them; I
made a minor error.
Yes, passing 0 (or NULL, if it's #defined as 0) to a non-prototyped
function expecting a pointer is an error. The fact remains that there
is code in the real world that makes this error, and happens to work
as expected on platforms where pointers are the same size as int and
the null pointer has the same representation as (int)0.
This is not enough to make it work. If the platform has separate data
and address registers, the value *may* be passed in the "wrong" register
and the code will fail miserably.
Fine, I didn't exhaustively list all the criteria necessary for such
code to work. My point (and it was a minor one) was that such code
does happen to "work" on some platforms, and some implementers *might*
cater to such code.
[snip]
I don't know why you keep invoking severely broken code that happens to
work by accident as an argument. Please show us some *concrete* evidence
that implementors care about such code when making their decisions and
that they're ready to sacrifice performance in order to keep broken code
working as intended by its developer.
I have no such concrete examples. I know of no real world
architecture on which there's a significant performance difference
between using all-bits-zero for null pointers and using some other
representation. (Though if using all-bits-zero also makes it easier
to catch errors, that might be a reason to use all-bits-zero even if
there is a slight performance penalty.)
I do have a couple of speculative examples where implementors *might*
have catered to "broken" code, though perhaps not at the cost of a
performance penalty. For most implementations, the argument passing
convention is such that printf() happens to work in many cases even
without a valid prototype. For most implementations, null pointers
are represented as all-bits-zero, even though using a different
representation would only break invalid code. Perhaps that's just
inertia.
But here's the actual context. Upthread, you wrote:
>> If all bits zero is an inconvenient representation for the null
>> pointer on a given platform, no implementor is going to use it
>> and there is no point in explaining how it could be used,
>> anyway.
I responded that I'm not convinced, and presented some possible
reasons why some implementors *might* do that. Perhaps nobody
actually would; at this point, I don't particularly care, and I doubt
that anyone else still following this thread does either.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.