I'm reading the C specification, which states in 6.5 Expressions
The effective type of an object for an access to its stored value is the declared type of the object, if any. If a value is stored into an object having no declared type through an lvalue having a type that is not a character type, then the type of the lvalue becomes the effective type of the object for that access and for subsequent accesses that do not modify the stored value.
Can anyone explain what this means? I've got a vague feeling that it has to do with pointers and malloc(), but that's as far as I can get without help from a lawyer...
Update based on answer: Can I safely do this?
struct point {
int x;
int y;
};
int main() {
int *x = malloc(1000);
*x = 10;
printf("%d\n", *x);
struct point *p = x;
p->x = 5;
p->y = 10;
printf("%d %d\n", p->x, p->y);
}
I'm getting a warning, but it works in my case. Is it guaranteed to work?