Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: noalias, again (was extern const) Message-ID: <10731@mimsy.UUCP> Date: 20 Mar 88 16:44:55 GMT References: <7712@apple.Apple.Com> <7485@brl-smoke.ARPA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 52 In article <7485@brl-smoke.ARPA> gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: >Basically, "noalias" is ... [long description deleted] > >I think I got that substantially right, although I may have messed >up a few details. Hey, I don't plan to use [noalias]! But you do plan to use the standardised language. If noalias is in the standard, and you do not understand noalias, you cannot use the C library effectively, because it *does* use noalias, and you may not ignore that. For instance, the latest draft says that the prototype declaration of `strcpy' is char *strcpy(noalias char *dst, noalias char *src); /* or perhaps char *noalias dst, but that is irrelevant here */ What this means to you, the programmer calling strcpy, is that the following code, which used to be legal and predictable, is now illegal and unpredictable [I think] BUT THE COMPILER CANNOT WARN YOU: f() { char buf[SIZE]; int n; ... /* remove leading junk (n < strlen(buf)) */ (void) strcpy(buf, buf + n); You must understand `noalias' to know why this has become illegal (which may only demonstrate that I do not understand it myself, if it is in fact legal under the above declaration). The point is that the standard library is now bestrewn with `noalias' declarations; these declarations make promises to the compiler; and you as a programmer are obligated to keep these promises, so you must know what they are and, when necessary, change your code where it violates them. The C library you have been using makes no such promises. There has been nothing to violate; now there is. If all the `noalias'es were removed from the library standard, you could start ignoring noalias. But.... Someday, somewhere, someone will supply you with an existing body of code---perhaps a library---that *does* use noalias, and you will have to understand noalias to use or modify that code. If it is a library and supplied in object form, you will not even have the option of removing all the `noalias' modifiers. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris