Alignment attribute

Eike Rathke list at
Mon Apr 15 00:38:27 UTC 2019


On Sunday, 2019-04-14 15:18:40 -0700, Kevin J. McCarthy wrote:

> On Sun, Apr 14, 2019 at 11:14:05PM +0200, Gero Treuner wrote:
> > Just drop that alignment?
> No, let's leave it.

Interested I took a glance and yes it should be kept.

> > Considering that Mutt doesn't control alignment on other data structures
> > and there seem to be no issues: Probably it is valid to assume that
> > compilers as GCC automatically choose a suitable alignment.
> Mutt isn't doing tricky things like this in other places, so there is
> probably a very good reason for the declaration.

The reason is that some processor architectures can't access words like
int or long on odd addresses and doing so would result in a violation.

Now there char buf[] is declared on the stack and without enforced
alignment would be allocated with a char alignment wherever the current
stack pointer happens to point at. Later char *ptr = buf is taken and
then casted

  const struct inotify_event *event = (const struct inotify_event *) ptr;

to further use it to access event->wd and event->mask. If these are not
properly aligned the program will crash.


OpenPGP/GnuPG encrypted mail preferred in all private communication.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Use LibreOffice!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <>

More information about the Mutt-dev mailing list