Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: A question about noalias and parameters. Message-ID: <6886@brl-smoke.ARPA> Date: 20 Dec 87 01:01:58 GMT References: <2063@bloom-beacon.MIT.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 30 In article <2063@bloom-beacon.MIT.EDU> wesommer@athena.mit.edu (William E. Sommerfeld) writes: >In other words, are the two programs here supposed to be equivalent? If I understand your intent correctly, I think the answer is Yes. By the way, this is not the only, nor even the main, use for noalias. Note that it is not usually the pointer itself being declared noalias, but rather the data it can access. If, for example, the function directly modifies an extern datum that could be accessed via a pointer-to-noalias parameter, that is indeed a violation of the "noalias" guarantee. It is not always possible to detect such a violation at compile time, and it is unlikely that any implementation other than a "safe development" one would try to detect such violations at run time. In the second program, The declaration of func() could have been void func(char *p1, char *p2, char *noalias *r1, char *noalias *r2); which I believe is a closer match to the way you were thinking. As it was, the data pointed to by v3 and v4 was being guaranteed to have no alias, which logically implies that v3 and v4 can also have no alias, but it doesn't directly state that. Basically, on the way into and out of a function, all buffered non-const "noalias" data reachable via parameters must "be returned to their seats" before the function starts and reloaded after the function returns. That's because the declaration promises that there are no aliases for the data, so to keep from being surprised by what the code does in the function, the promise has to be enforced across function boundaries. I hope I explained this right. It's hard doing from memory, without having the final rules available at this time..