Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!lll-lcc!well!msudoc!crlt!michael From: michael@crlt.UUCP Newsgroups: comp.arch Subject: Re: Abusing pointers (was: Available no. of registers) Message-ID: <646@crlt.UUCP> Date: Fri, 20-Feb-87 13:45:10 EST Article-I.D.: crlt.646 Posted: Fri Feb 20 13:45:10 1987 Date-Received: Sun, 22-Feb-87 10:44:17 EST References: <749@cullvax.UUCP> Organization: McClary Associates, Ann Arbor MI Lines: 37 Summary: Oh, really? Where did they say so? In article <1029@cuuxb.UUCP>, mwm@cuuxb.UUCP (Marc W. Mengel) writes: +> Unfortunately, you don't have to take the address of a given variable +> to use it, you merely have to take the address of a variable near it +> and add an offset to it. The way C is defined, this is quite legal. +> +> For example, suppose I have a function f, declared as follows: +> f(p) +> struct { int a, b, c; } *p; +> { +> ... +> } +> And I call it as follows: +> b() +> { +> int a, b, c; +> +> f( &a ); +> } +> According to our venerable friends kerningham&ritchie, this is legal; +> it is also used to some great extent in the older (v6 & v7) unix kernels. I have heard that this is used in a number of kernels, and of course it would work in a lot of compiler-generated code that didn't do tricks with registers or storage allocation, and didn't waste a lot of processor and programmer effort trying to "protect" you against your folly, but where do K&R come out and say it is legal? I just re-read the source I think would be the most likely place (the "pointers" chapter of the sky-blue C book) and didn't find it. =========================================================================== "I've got code in my node." | UUCP: ...!ihnp4!itivax!node!michael | AUDIO: (313) 973-8787 Michael McClary | SNAIL: 2091 Chalmers, Ann Arbor MI 48104 --------------------------------------------------------------------------- Above opinions are the official position of McClary Associates. Customers may have opinions of their own, which are given all the attention paid for. ===========================================================================