#pragma does only half the job (was Re: Pragma and noalias)

00704a-Liber nevin1 at ihlpf.ATT.COM
Fri Jul 8 11:21:41 AEST 1988


In article <423 at proxftl.UUCP> bill at proxftl.UUCP (T. William Wells) writes:

>This would mean that writing strcpy as:
>
>	char *
>	strcpy(p1, p2)
>	char    *p1;
>	char    *p2;
>	#pragma noalias p1[],p2[];
>	{
>		...
>	}
>
>is ok, because, given that the assertion (that p1 and p2 are not
>aliased) is true, should the compiler make that assumption, the
>program will be still correct.

But, as Dennis Ritchie pointed out in his 'noalias must go' declaration (BTW,
I kept a copy of it and I have been emailing it to all those who have
requested it):

|	     A substantial fraction of the library cannot be
|	expressed in the proposed language.
|	
|	     One of the simplest routines,
|	
|	        char *strchr(const noalias char *s, int c);
|	
|	can return its first parameter.  This first parameter must
|	be declared with `const noalias;' otherwise, it would be
|	illegal (by the constraints on assignment, 3.3.16.1) to pass
|	the address of a const or noalias object.  That is, the type
|	qualifiers in the prototype are not merely an optional
|	pleasantry of the interface; they are required, if one is to
|	pass some kinds of data to this or most other library routines.

Specfically, in your example, strcpy() returns an ALIAS to p1, which by
the definition of noalias is not allowed.
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				You are in a little twisting maze of
 /  / _ , __o  ____		 email paths, all different.
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah



More information about the Comp.lang.c mailing list