关于限制指针的规则,我有点困惑.也许有人可以帮助我.
定义嵌套的受限指针是否合法,如下所示:
int* restrict a;
int* restrict b;
a = malloc(sizeof(int));
// b = a; <-- assignment here is illegal, needs to happen in child block
// *b = rand();
while(1)
{
b = a; // Is this legal? Assuming 'b' is not modified outside the while() block
*b = rand();
}
Run Code Online (Sandbox Code Playgroud)导出受限指针值是否合法,如下所示:
int* restrict c;
int* restrict d;
c = malloc(sizeof(int*)*101);
d = c;
for(int i = 0; i < 100; i++)
{
*d = i;
d++;
}
c …
Run Code Online (Sandbox Code Playgroud)