The following code:
float *P;
P = (float*)&P;
P[0] = 0.0f;
violates the rule of strict smoothing.
An object Phas an effective type float *because it is its declared type. C11 6.5 / 6:
An effective type of object for accessing its stored value is the declared type of the object, if any.
P[0] , P. (: sizeof(float) == sizeof(float *) . , , !)
P[0] = 0.0f lvalue float float *. 6.5/7:
, lvalue,
"" . " " , float a float *
, . , :
float *Q;
float *P = &Q;
*P = 0.0f;
Q float *, lvalue float.
. , , . P[0] = 0.0f P. , P , - , P - .
P[1] = 0.0f . memset; memset P[1], P[1] P[0] = ....;. .
, , memset, , .
NB. P = (float *)&P . . ( "" ).