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

T. William Wells bill at proxftl.UUCP
Mon Jul 11 16:55:12 AEST 1988


In article <5240 at ihlpf.ATT.COM>, nevin1 at ihlpf.ATT.COM (00704a-Liber) writes:
> 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):

> [something from dmr, omitted]

> Specfically, in your example, strcpy() returns an ALIAS to p1, which by
> the definition of noalias is not allowed.

Upon reading your response my first idea was to flame you for
not having read my posting carefully. Instead, I get to flame
myself. (snap, crackle, whoosh: OK, you idiot, why didn't you
say that your #pragma was different from the proposed noalias
keyword? :-)

Anyway, here is what I should have inserted into my posting:

"I might define a

	#pragma noalias declarator_list;

which asserts that, should an expression of a form equivalent to
one of these declarators be used to modify an object, that
object will not be referencable by means of an expression of a
form equivalent to any of the other declarators."

In the given example, the only thing that the compiler may
assume is that, since p1[] is going to be modified, p2[] will not
be.

I am aware that my example #pragma is a little rough around the
edges, but since I only needed it as an example, I am not going
to elaborate on how it might be fixed up.



More information about the Comp.lang.c mailing list