On Thursday 26 May 2005 00:07, Jon Nelson wrote:
That's not a bug.
Yes it is
Perhaps it's not the best style (and in this particular case, even that is debatable), but there's nothing technically wrong with it.
Yes there is
A void * must be able to hold the largest pointer value, and since you can't pass anything larger than a single pointer value in C, it's not a problem.
First of all, what do you mean by this? You can pass entire structs by value in C. It's perhaps not advisable from a performance point of view, but that's another issue. Secondly, there is nothing to guarantee that a pointer is stored in any form suitable to hold an integer. There are platforms where pointers are complex structures not at all suitable for storing integers. It is also possible that a pointer is 32 bit while an integer is 64 bit. The only thing guaranteed by the standard is that short <= int <= long and that a char is 8 bits. Nothing else regarding size is guaranteed, certainly not an equality between sizeof(int) and sizeof(void *) On x86 platforms and some others, you are usually lucky when you do this, because a pointer happens to be an integer there. But it is not guaranteed by the standard. A compiler would be free to do whatever it pleases after such a case. It is known as undefined behaviour and it is most definitely a bug, even though it may work on a few popular platforms
Technically, he *could* pass the /value/ of the /address/ of t,
commonly known as a pointer, yes, you can cast (int *) to (void *)