Hacker News new | ask | show | jobs
by gizmo686 406 days ago
> 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

As I read it, this means that

  struct foo *x = malloc(sizeof(*x))
Will have an effective type of "struct foo*", which seems like what you would expect.
1 comments

But if then you write to that memory through a int pointer the effective type is int. Unlike if you would have allocated the struct in the stack.