For this test case, I think the second assertion MAYALIAS(z, &obj1) should be NOALIAS?
This is because in the if-else branch, both a and b are equal to &z, and when calling foo(a,b), the *b will be updated to &obj2. Hence, z and &obj2 are MayAlias, but z and &obj1 are NoAlias.
// cs_tests/cs8.c
#include "aliascheck.h"
int obj1,obj2;
void foo(int **p, int **q){
*p = &obj1;
*q = &obj2;
}
int main(){
int **a,**b,*x,*y,*z;
if(a){
a = &x;
b = &y;
}
else{
a = &z;
b = &z;
}
foo(a,b);
MAYALIAS(x,&obj1);
MAYALIAS(z,&obj1);
MAYALIAS(y,&obj2);
MAYALIAS(z,&obj2);
NOALIAS(x,&obj2);
}
Yes, you are correct. But the underlying analysis is calling-context-sensitive but not branch-insensitive.... Feel free to develop more precise analysis derived from this case:)
Hi,
For this test case, I think the second assertion
MAYALIAS(z, &obj1)
should be NOALIAS?This is because in the
if-else
branch, botha
andb
are equal to&z
, and when callingfoo(a,b)
, the*b
will be updated to&obj2
. Hence,z
and&obj2
are MayAlias, butz
and&obj1
are NoAlias.