Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!ut-sally!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.lang.c Subject: Failure of "long x(cp) char * cp; { return *((long *) cp); }" is a bug? Message-ID: <6152@elsie.UUCP> Date: Sat, 28-Jun-86 17:02:03 EDT Article-I.D.: elsie.6152 Posted: Sat Jun 28 17:02:03 1986 Date-Received: Mon, 30-Jun-86 03:26:59 EDT Organization: NIH-LEC, Bethesda, MD Lines: 33 As I understand it, the code produced by some compilers from long x(cp) char * cp; { return *((long *) cp); } will cause core dumps if the value of cp isn't "appropriately aligned". When dealing with such compilers, you get to do something like long x(cp) char * cp; { long l; function_to_do_arbitrary_copying((char *) &l, cp, sizeof l); return l; } to avoid core dumps. Isn't this really a compiler bug? Doesn't the cast in the return *((long *) cp); give the compiler all the evidence it needs that it should, *on its own*, produce code that's the equivalent of the function call? Does the latest version of X3J11 have anything to say on the matter? -- Bug/s is a Volkswagen/Warner Brothers trademark. -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX, Elsie & Ado are Digital, Borden & Shakespeare trademarks.