The function \'foo\' in the snippet below will load only one of the struct members A or B; well at le
No, if *P
is allocated correctly P->B
will never be in unallocated memory. It might not be initialized, that is all.
The compiler has every right to do what they do. The only thing that is not allowed is to oops about the access of P->B
with the excuse that it is not initialized. But what and how they do all of this is under the discretion of the implementation and not your concern.
If you cast a pointer to a block returned by malloc
to Pair*
that is not guaranteed to be wide enough to hold a Pair
the behavior of your program is undefined.