Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site ssc-vax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!ssc-vax!savage From: savage@ssc-vax.UUCP (Lowell Savage) Newsgroups: net.lang.c Subject: Re: Type modifiers in C (scope/extent discussion) Message-ID: <344@ssc-vax.UUCP> Date: Wed, 6-Nov-85 15:28:07 EST Article-I.D.: ssc-vax.344 Posted: Wed Nov 6 15:28:07 1985 Date-Received: Thu, 7-Nov-85 06:48:07 EST References: <943@lll-crg.ARpA> <177@opus.UUCP> <389@graffiti.UUCP> <199@opus.UUCP> Organization: Boeing Aerospace Co., Seattle, WA Lines: 51 > > > ...(In some > > > languages it would be prohibited to assign the address of an automatic > > > variable to a more global pointer--i.e., a pointer whose extent exceeds > > > that of the variable.) > > > > I hope they never put that in 'C'. After all... > > > > char *myname; > > ... > > main(ac, av) > > int ac; > > char **av; > > { > > ... > > myname=av[0]; > > ... > > } I think that this rule is talking about something more like one of the following cases: char *cpt; ffoo() ... { char *cpt; foo() cpt = foo(); { ... char ch[10]; } ... foo() cpt = ch; { char ch[10]; ... ... } return (ch); } the C compiler should catch these (or at least lint should) since 'ch' may go away before the next time cpt is dereferenced. Now this should be okay if 'ch' is static, because then it will still be around no matter when you dereference 'cpt'. Also, you know that the only way to get to 'ch' is to call foo, you can't just use it. Now if some idiot programmer still wants to muck around with the data stored in 'ch' by dereferencing 'cpt', that's his business. But since (at least one of) the main purpose(s) of foo is calculate 'ch' it shouldn't depend on any previous data in foo. These are my own personal biases. Anyone that wants to share them will have to fill out a 100-page non-disclosure agreement in octuplicate (without carbons), send all copies with 2 dollars for processing to outer Tanzania, wait two years, and chant "Mousy Dung was a bad guy." five hundred times. All questions on this matter will be refered to the Bureau of non-violent violence (BNVV)...or was that the Association for the Promulgation of Persons Against Associations (APPAA)? There's more than one way to be savage Lowell Savage