Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!uwvax!topaz!bentley!kwh From: kwh@bentley.UUCP (KW Heuer) Newsgroups: net.lang.c Subject: Re: void * Message-ID: <743@bentley.UUCP> Date: Thu, 24-Apr-86 13:59:13 EST Article-I.D.: bentley.743 Posted: Thu Apr 24 13:59:13 1986 Date-Received: Sat, 26-Apr-86 04:42:45 EST References: <200@brl-smoke.ARPA> Organization: AT&T Bell Laboratories, Liberty Corner Lines: 26 In article <200@brl-smoke.ARPA> gwyn@BRL.ARPA (VLD/VMB) writes: >You're mixing two features of malloc(). Malloc() should return (void *), >which is a generic pointer type to/from which all other pointer types >may be cast without loss of information. (This is the only use of >(void *), and it is the only universal pointer type; other pointer >casts can be non-portable.) Malloc() ALSO guarantees that the pointer >it returns is suitably aligned for safe casting to ANY pointer type. >This is a property of malloc(), not of (void *). I realize that; it's just that I was expecting the new datatype to correspond to this property of malloc(), so malloc() wouldn't have to be a special case. I probably shouldn't have brought up this (ALIGN *) issue in the same posting. It's *not* true that (void *) can always be cast into another pointer type without loss of information. For example, "intp = voidp;" may drop bits if "voidp" was initialized to an improperly aligned object. What's true is that any pointer may be assigned *to* a void pointer, and that *same* value may be safely copied back. (Currently this is a guaranteed feature of (char *).) To rephrase my original question, what does this have to do with the explicit use of the cast operator? Is "intp = voidp;" going to be as acceptable as the (more correct, to me) syntax "intp = (int *)voidp;"? Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint