Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!ucbvax!agate!aurora!amelia!ames!nrl-cmf!cmcl2!brl-adm!umd5!cvl!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: comp.lang.c Subject: "Noalias" warning and questions Message-ID: <8012@elsie.UUCP> Date: 11 Feb 88 18:44:05 GMT Organization: NIH-LEC, Bethesda, MD Lines: 49 X3J11 has now mailed out copies of the January 11, 1988 versions of the Draft Proposed C Standard and the Rationale. It looks as if folks planning to make use of standard library functions won't have the luxury of simply ignoring "noalias". The Rationale (which contains what were to me enlightening words on "noalias") notes that "Declaring a pointer-type function parameter to be noalias enjoins the caller of that function to assure that the object referenced by that pointer overlaps with no other parameter object." Since many standard library functions have prototypes that declare arguments to be "noalias", you'll need to ensure that there's no such overlap when you call them. Now a bit of background for a few questions. Here are two function prototypes from the proposed Standard: int strcmp(const noalias char *s1, const noalias char *s2); void perror(const noalias char *s); 1. Does the program #include "stdlib.h" main() { char array[3]; array[0] = '\0'; return strcmp(array, array); } violate any constraints? If so, must the compiler detect the violation? 2. Does the program #include "stdlib.h" main() { char array[3]; char * p, q; array[0] = '\0'; p = array; q = array; return strcmp(p, q); } violate any constraints? If so, must the compiler detect the violation? 3. Remembering that identical string literals may not be distinct, might the program #include "stdlib.h" main() { return strcmp("walla", "walla"); } violate any constraints? If so, must the compiler detect the violation? 4. What is the "noalias" in the "perror" declaration designed to do? -- ado@vax2.nlm.nih.gov ADO, VAX, and NIH are Ampex and DEC trademarks