Sun Studio 12: C User's Guide

5.3.1 Struct Pointer Cast of Scalar Pointer

In the following example, the pointer p of type integer is cast as a pointer of type struct foo. With lint -Xalias_level=weak (or higher), this generates an error.


struct foo {
    int a;
    int b;
  };

struct foo *f;
int *p;

void main()
{
    f = (struct foo *)p; /* struct pointer cast of scalar pointer error */
}