Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-tgr!tgr!art@acc.arpa From: art@acc.arpa Newsgroups: net.lang.c Subject: RE: type cast in initializer Message-ID: <2124@brl-tgr.ARPA> Date: Fri, 31-Jan-86 19:08:54 EST Article-I.D.: brl-tgr.2124 Posted: Fri Jan 31 19:08:54 1986 Date-Received: Mon, 3-Feb-86 04:56:35 EST Sender: news@brl-tgr.ARPA Lines: 23 > I've found the two lines > > int x = 0; > char *ptr = (char *) &x; > > acceptable to every C compiler I've used, until running into the > Whitesmith's C compiler. They refuse to accept the type coercion "(char *)" > on the second initialization. As I read K&R this should be acceptable > through the rules The posting did not indicate whether the variables are static or auto. The initializer should be legal if x is static, but not neccesarily if x is declared as an auto. If x is auto, the compiler could place it in a register whose address cannot be taken. The compiler should be smart enough to notice the address operator and disallow register allocation. K&R only states that variables declared register cannot have their address taken. Anyone know what ANSI says? ------