Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!ll-xn!cit-vax!nike!think!ima!haddock!karl From: karl@haddock Newsgroups: net.lang.c Subject: Re: void* Message-ID: <86900014@haddock> Date: Fri, 15-Aug-86 17:41:00 EDT Article-I.D.: haddock.86900014 Posted: Fri Aug 15 17:41:00 1986 Date-Received: Sun, 17-Aug-86 07:29:02 EDT References: <5937@alice.uUCp> Lines: 20 Nf-ID: #R:alice.uUCp:5937:haddock:86900014:000:1074 Nf-From: haddock!karl Aug 15 17:41:00 1986 alice!bs (Bjarne Stroustrup) writes: >In addition, the draft ANSI C proposal allows uncasted assignment of a void* >to a non-void pointer. This, I consider to be an unnecessary weakening of C's >type system; in the long run it will become a rather serious nuiscance. I agree that this is a bad idea; I'm glad to hear that C++ disallows it. If you don't want to cast the result of malloc(), it's easy to hide it in macros (I've been doing it for years): #define new(type) ((type *)malloc(sizeof(type))) #define nnew(n, type) ((type *)malloc((n)*sizeof(type))) This does restrict "type" to something you can add "*" to, though. Having said that, I'll now point out that X3J11 draft 01-May-1986 does say in 5.5 (Common Warnings), "[An implementation may generate a warning if] an implicit narrowing conversion is encountered, such as the assignment of ... a pointer to void to a pointer to any type of object other than char." This implies that such an uncasted assignment should be avoided, at least. Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint