[Bug c/60360] New: __attribute((aligned(...))) changes sizeof(...) of struct

dabler at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 27 17:39:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60360

            Bug ID: 60360
           Summary: __attribute((aligned(...))) changes sizeof(...) of
                    struct
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dabler at gmail dot com

If the __attribute((aligned(...))) is used on structure, a size reported by
sizeof(...) operator is affected. Example:

struct strtype {
    int i;
} __attribute((aligned(64))) s;

printf("%zu\n", sizeof(s));

This is in contrast with the behavior on other types, e.g. int type.

int i __attribute((aligned(64)));

printf("%zu\n", sizeof(i));

I believe that there is no reason to change sizeof(...) of the given struct
because an alignment can be determined by __alignof(...) operator.



More information about the Gcc-bugs mailing list