Re: Packing of structure fields and whole structs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux