Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcnc!rti!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: news.software.b,comp.lang.c Subject: (void *) & casting the pointer returned by malloc Message-ID: <1827@dg_rtp.UUCP> Date: Mon, 4-May-87 15:59:08 EDT Article-I.D.: dg_rtp.1827 Posted: Mon May 4 15:59:08 1987 Date-Received: Tue, 5-May-87 05:18:29 EDT References: <18346@ucbvax.BERKELEY.EDU> <145@sds.UUCP> Lines: 29 Summary: Emma finds that (void *) is not a generic pointer type, Steed converts a value from malloc Xref: mnetor news.software.b:591 comp.lang.c:2053 > allbery@ncoast.UUCP (Brandon Allbery) > | guy%gorodish@Sun.COM (Guy Harris) > | 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. > (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 !mcnc!rti!dg_rtp!throopw