Re: pointer q




"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx>
Joe Smith wrote:
"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx>
[ill-advised and illegal stuff]
short *sp;
*sp = (short)*lp; /* ill-advised, but Let's Pretend */

Writes through an uninitialised pointer which is undefined behaviour.
Is it the miscast here that creates the unitialized pointer?

I think if a fellow were serious, ie, trying not to do illegal or
ill-advised things, and he wanted to "pick apart" something that the
compiler has stored as a long at an address accessible to the source, he
would go after it with the last of those options, unsigned chars, and
make the necessary conversions to make zeroes and ones.

Yes, using unsigned char would be the correct way to pick it apart, and
indeed there are sometimes good reasons for doing this.. You still have to
watch out for endianness and be aware that different implementations have
different length longs.
It seems to me that indeed this would be a way to discern endianness.

There's something driving me bats right now. How does one complete this
table:

long * | short | long ***
-------------------------------------------------
type is | | |
----------------------------------
type-specifier is | | |

You should really use a fixed width font when doing things like tables. It
may have looked formatted on your machine, but here it looks a right mess,
and I'm not going to try all my fonts on the off chance one uses the same
spacings as whatever font you used.

The type specifiers in the above are short and long. The types are long*,
short and long***.
Crap, I was really proud of that, using only the space bars for spaces and
explicit carriage return. Alles klar on the answer. joe


.