Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: const void * Message-ID: <3723@haddock.ISC.COM> Date: 29 Apr 88 22:41:37 GMT References: <6214@cit-vax.Caltech.Edu> <6268@cit-vax.Caltech.Edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Distribution: na Organization: Interactive Systems, Boston Lines: 19 In article <6268@cit-vax.Caltech.Edu> andy@csvax.caltech.edu (Andy Fyfe) writes: >What does (or should?) the ANSI standard say about const void *? Should say: All conversions between (any *) and (void *), with arbitrary type qualifiers on either, are legal operations; but converting from const to non- -const or from (void *) to any pointer type other than (void *) or (char *), except by means of an explicit cast, is a Common Warning. Does say: Something too restrictive, as Dennis has pointed out. Has this been resolved yet, Doug? >As an aside, K&R 2 (section 7.8.5) makes it clear that the pointer returned >by malloc must explicitly be cast to the correct pointer type. Why is this >required, given that malloc returns a "void *"? Probably to avoid the Common Warning. The compiler doesn't know that the result of malloc is maximally aligned; (void *) generally isn't. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint