Andrew Haley wrote:
Phil Endecott writes:
> char c;
> struct foo f; // unaligned
>
> func(&f.a);
>
> it won't work, because func() assumes that the pointer it is passed
> is aligned.
> But I don't get any error or warning when I do this. Would you
> agree that an error (or at least a "big fat warning") would be
> appropriate at the point where I wrote &f.a?
Not necessarily. It's perfectly appropriate to do something like:
memcpy (&f.a, foo, sizeof f.a);
Yes, but you can observe that memcpy takes a void* and not generate a
warning in that case.