https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82265

            Bug ID: 82265
           Summary: packed attribute on variables in gcc-7.1.1 no more
                    accepted
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: etienne_lorrain at yahoo dot fr
  Target Milestone: ---

Compiling the simple line on amd64:
long long a __attribute__((packed)) = 100;
with "GCC: (GNU) 7.1.1 20170622 (Red Hat 7.1.1-3)"
gives the warning:
tmp.c:1:1: warning: ‘packed’ attribute ignored [-Wattributes]
and we can verify it is really ignored, variable "a" is aligned to 8 bytes.

while it is documented in:
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes

packed:     The packed attribute specifies that a variable or structure field
should have the smallest possible alignment

The packed variable was (previous compiler versions) the only way to reduce
alignment of variables (for instance long long or strings), attribute
aligned(1) now works (reducing alignment) but is documented as "specifies a
minimum alignment", not forcing alignment.

Thanks, Etienne.

Reply via email to