Path: utzoo!attcan!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.JUNET (Norman Diamond) Newsgroups: comp.lang.c Subject: Re: Do you have to cast void pointers when dereferencing them? Keywords: (With ANSI C) Message-ID: <10094@socslgw.csl.sony.JUNET> Date: 23 Dec 88 05:35:33 GMT References: <2414@ssc-vax.UUCP> <15012@mimsy.UUCP> <3050@arcturus> <773@auspex.UUCP> Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 24 In article <773@auspex.UUCP>, guy@auspex.UUCP (Guy Harris) writes: > ... some > compilers may object to converting a "char *" to an "int *" without a > cast (not because they don't know how to do it, but because it's not > *required* to be permitted by the dpANS, and because it could be > difficult or impossible in some implementations). ^^^^^^^^^ ^^^^^^^^^^ I've got bad news for those compilers. They may not object to converting a "void *" to an "int *" and that "void *" must have the same representation as a "char *". So if it's difficult, they have to do difficult things. If it's impossible, then they don't have C and they never had malloc(). Sure, any code that ever used malloc() before the invention of (void *) was already broken, right? So ANSI isn't really breaking working code. But to be sensible, compilers really ought to allow conversion between (char *) and other pointer types. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-inventing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?