Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: net.lang.c Subject: Re: icky C code Message-ID: <3221@utcsri.UUCP> Date: Sun, 3-Aug-86 23:28:28 EDT Article-I.D.: utcsri.3221 Posted: Sun Aug 3 23:28:28 1986 Date-Received: Wed, 6-Aug-86 10:24:06 EDT References: <2239@brl-smoke.ARPA> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 34 Summary: In article <19880@rochester.ARPA> crowl@rochtest.UUCP (Lawrence Crowl) writes: >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 ). > >Since there is no type checking between an external definition of a function There is lint, which does this. >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. > >So, the optimization would probably break some programs. Very likely, but only incorrect ones. This 'implicit casting' is not legal C. It is much the same as passing an int to a function which expects a struct containing a single int - it will usually work, but if (when) it doesn't, the programmer is at fault. Would you call that 'implicit casting'? I assert that a 68K C implementation could be made which returns pointers in A0 and ints in D0, and no lintable program would be broken. (If this is not the case, then lint needs work :-) ) -- "You'll need more than a Tylenol if you don't tell me where my father is!" - The Ice Pirates ---------------------------------------------------------------------- Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg