Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!crowl From: crowl@rochester.ARPA (Lawrence Crowl) Newsgroups: net.lang.c Subject: Re: icky C code Message-ID: <19880@rochester.ARPA> Date: Fri, 1-Aug-86 23:03:05 EDT Article-I.D.: rocheste.19880 Posted: Fri Aug 1 23:03:05 1986 Date-Received: Sat, 2-Aug-86 21:56:35 EDT References: <2239@brl-smoke.ARPA> <2446@umcp-cs.UUCP> <3117@utcsri.UUCP> <688@mordred.purdue.UUCP> Reply-To: crowl@rochtest.UUCP (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 24 In article <3117@utcsri.UUCP>, greg@utcsri.UUCP (Gregory Smith) writes: > From a code efficiency > standpoint, for example, a 68000 should return int's in D0 and all pointer > types in A0, which would break the above. ( Somebody pointed out that a > certain 68K compiler has an option to return both types in *both* regs ). > Or am I wrong, and there is a non-unwritten ( i.e. official ) rule that > says everything should return in the same reg whenever possible? Since there is no type checking between an external definition of a function and its actual definition, a programmer could implicitly type cast by listing the external definition with a different return type than the actual. If integers are put in D0 and addresses in A0, then the calling function would grab the return value from the wrong register. extern int f() ; BUT usage( ) { int i = f() ; } char *f() { return "ptr" ; } /* grabs from D0 */ /* puts in A0 */ So, the optimization would probably break some programs. -- Lawrence Crowl 716-275-5766 University of Rochester crowl@rochester.arpa Computer Science Department ...!{allegra,decvax,seismo}!rochester!crowl Rochester, New York, 14627