I've heard that it is not allowed to cast a pointer from one type to another, but I don't understand why.
For example, in the following code, all I do is reading the casted value, so how can things go wrong, if they can?
struct Foo {
int a, b, c, d;
};
int main() {
Foo f = {1, 2, 3, 4};
int *abcd = *((int *)&f);
// Now I should be able to access the values like:
int a = abcd[0];
int b = abcd[1];
// Then, I only read the values
// ...
return 0;
}