在下面的示例中,结构成员 foo.b 的地址被强制转换为结构指针,然后指定给 f2。如果 lint -Xalias_level=weak(或更高),这将生成错误。
struct foo{
int a;
int b;
};
struct foo *f1;
struct foo *f2;
void main()
{
f2 = (struct foo *)&f1->b; /* cast of a scalar pointer to struct pointer error*/
}
|