Philip said:
Richard wrote: [...]
No. I think it's important to show that these systems really
exist. Otherwise a lot of people will think it's all a lot of hot
air. It does no harm to demonstrate WHERE the standard benefits the
programmer. Not some airy fairy "there might be a system with a 13 bit
char" for example.
But again, if you don't know how things are done on systems, you will be
protected from it. I know that NULL is not guaranteed to be
all-bits-zero, and I don't know where it is and where it isn't. I'm not
even sure whether or not NULL is all-bits-zero on x86, and I'm happy to
stay that way.
It's good to have a couple of examples of why certain common assumptions
shouldn't be relied on, but compiling a comprehensive list is asking for
people to rely on that list instead.
A "comprehensive list" also runs into the issue of finding "real
world" examples for all such things. Suppose, for example, that
you came up with CHAR_BITS != 8, NULL not all-bits-zero, and a
whole bunch of others, but couldn't find a system where int's
have padding bits which may be different between two ints of the
same value. Might that add to the impression that that particular
"rule" could be safely ignored?
(That's not to say that I don't have memsets on structs with
pointers in them, to set the pointers to NULL. But, I am aware
of the situation, and the application already has a bunch of
system-dependent code in it, so this particular issue is not of
concern -- for this application.)
[...]
Give me an example of code which relies on -1 being all-bits-one.
Toggling bits by xor-ing with -1.
I used to work on a platform where function pointers were 32 bits
and data pointers were 16 bits. You can't store a generic array
of function pointers in an array of void pointers.
Why is that question relevant if noone tries to do it? I don't see you
asking for a list of platforms where NULL is 0xdeadbeef, because no code
depends on that.
There's a world of difference between assuming NULL is 0xdeadbeef
and assuming NULL is all-bits-zero. For latter is often done in
code which memsets structs to zero.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |
www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net |
www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:
[email protected]>