The func can be implemented like this:
float func(int *i, float *f) {
*i = 42;
return *f;
}
Since the compiler assumes that the pointers i and f do not alias, it has a right to generate the code that is equivalent to: float func(int *i, float *f) {
float result = *f;
*i = 42;
return result;
}
But this will change the result of the function. So in practice if you want to do type punning using unions, the compiler must know about it.