Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: some objections to 'noalias' Message-ID: <512@cresswell.quintus.UUCP> Date: 8 Jan 88 02:13:13 GMT References: <485@cresswell.quintus.UUCP> <1453@cuuxb.ATT.COM> <6971@brl-smoke.ARPA> Organization: Quintus Computer Systems, Mountain View, CA Lines: 55 Summary: this is a joke, right? In article <6971@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <1469@cuuxb.ATT.COM> mmengel@cuuxb.UUCP (Marc W. Mengel) writes: > > > Aliasing is not a problem in C. Ensuring that it is not a problem is > > expensive. People want to be able to turn off this expensive behavior > > in specific cases where they know that it won't make a difference. > > (This is such a beautiful statement of what "noalias" is all about that > I wanted to make sure everyone noticed it. Please excuse the reposting.) This is such a CONFUSING statement that I too want to make sure everyone notices it. Is he talking about the compile-time cost of checking whether something is aliased or not, or about the usually small run-time cost of picking up another copy of something from memory just in case it was aliased? [If someone has an example of a real program where adding 'noalias' to fewer than 10% of the variables makes a factor of 2 difference to run time, let's see it!] If whatever-it-is is so expensive, shouldn't the cheap version be the default (as it is in Fortran, Pascal, COBOL, ADA, BASIC, Euclid, and so on) and the expensive version be the one you have to say explicitly? What we need at this point is a CLEAR description of exactly what the difference is between volatile int x; int x; noalias int x; Are they points on a scale: volatile: may change at any time {plain}: may change in any *procedure call* noalias: may only change by explicit assignment If I say cat >>foo.h <<'EOF' extern noalias int x; extern void set_x(int i); EOF cat >>foo.c <<'EOF' noalias int x; void set_x(int i) { x = i; } EOF cat >>main.c <<'EOF' #include #include "foo.h" main() { x = 0; set_x(1); printf("x = %d\n", x); } EOF cc main.c foo.c a.out is the output x = 0 legal? {Presumably such a program is non-conforming, but is a conforming compiler allowed to do this to it?}