
(void *) & casting the pointer returned by malloc
Quote:
> | 1) Your program will *also* have problems if you define NULL as
> | "(void *)0", if "(char *)0" and "(void *)0" don't have the same
> | representation.
> Pardon me???! (void *) is a GENERIC pointer, is it not? It should, in
> theory, be a type pun in all situations
(void *) is NOT a generic pointer type. There is no such beast in C,
and I for one hope nobody introduces one. And even if there were a
generic pointer type, one should NOT assume that it is a type pun for
all non-generic pointer types.
Quote:
> (if casting the result of a rational
> malloc() (defined as returning (void *)) changes the representation of the
> pointer returned, we've got trouble, no?).
Quite the reverse, on some machines. For example, on word-addressed
machines malloc must return a pointer with the finest possible
granularity. Yet the pointer format for most types will have coarser
resolution. Thus, if the cast of the return value of malloc does NOT
change the representation, then there's trouble in River City, and HOW.
--
"They pelted me with rocks and garbage."
--- David Letterman
--
Wayne Throop <the-known-world>!mcnc!rti!dg_rtp!throopw