noalias, again

Doug Gwyn gwyn at brl-smoke.ARPA
Mon Mar 21 21:35:50 AEST 1988


In article <10731 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>		/* remove leading junk (n < strlen(buf)) */
>		(void) strcpy(buf, buf + n);
>You must understand `noalias' to know why this has become illegal

This usage was never a good idea, because a valid implementation of
strcpy() would be to copy right-to-left rather than left-to-right
through the source string, in which case the first n bytes of the
result would not be what you expect.  All that the addition of
noalias to the official interface spec does is to warn you about
this fact (of which you were apparently unaware).  Thus your
example helps make a case for noalias being in the spec!

On the other hand, strcpy() between NON-OVERLAPPING portions of an
array is supposed to be valid, so if the noalias wording doesn't
agree with that, we'll have to fix it.



More information about the Comp.lang.c mailing list