This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] lno branch merge -- vectorizer patch #1
On Wed, 4 Aug 2004, Daniel Jacobowitz wrote:
> But actually this isn't true. This is legitimate:
> void func (int * restrict a, int * b)
> {
> a[0] = b[0];
> a[1] = b[1];
> }
>
> func (&c[3], &c[2]);
>
> The write of a[0] (through a restricted pointer) and read of b[1]
> (through a non-restricted pointer) conflict.
And therefore the code is invalid. In the notation of 6.7.3.1:
D is the parameter declaration "int * restrict a".
P is a.
T is int.
B is the body of func.
L is "a[0]", an lvalue which has &L based on P.
X, the object L designates, is c[3].
L is used to access the value of X (specifically, to modify it, one of the
two types of access under 3.1#1).
X is modified (by that access).
So the following requirements apply:
T shall not be const-qualified (OK).
Every other lvalue used to access the value of X shall also have its
address based on P (not OK, the lvalue "b[1]" is not based on P). As this
isn't satisfied, there is undefined behavior, and we don't need to look at
the other requirements.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)