Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 ggr 10/10/85; site bentley.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!bentley!kwh From: kwh@bentley.UUCP (KW Heuer) Newsgroups: net.lang.c Subject: void * Message-ID: <728@bentley.UUCP> Date: Mon, 21-Apr-86 22:45:37 EST Article-I.D.: bentley.728 Posted: Mon Apr 21 22:45:37 1986 Date-Received: Wed, 23-Apr-86 21:45:35 EST References: <1883@ucsfcgl.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner Lines: 26 In article <1883@ucsfcgl.UUCP> ucsfcgl!arnold (Ken Arnold%CGL) writes: >Purists will note that I really should say > ptr = (some_type *) malloc(10 * sizeof *ptr); >But eventually malloc() will be of type "void *". Okay, enlighten me. When I first saw the idea of "void *" I thought it was to be a name for the most restrictive pointer type ("ALIGN *" for those who know the malloc source). Then when I rechecked, I found that it was a new name for the least restrictive pointer type, "char *". Now you seem to say that the cast operator is unnecessary in your example. I'd like some more detail about this beast. Specifically, suppose we have the following: void *v; char *c; short *h; ALIGN *a; Of the 12 nontrivial assignment statements, which ones will ANSI C accept without a cast? What will lint accept (with/without cast)? Currently lint warns about things like h=c because it doesn't know whether c is aligned properly for use as a short pointer. Thus every nontrivial use of malloc, even with the appropriate cast, generates a lint warning. This is why I thought that "void *" was going to mean "ALIGN *", which would be the appropriate return value for malloc(). (Also more efficient, on word-based machines.) Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint