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

            Bug ID: 89968
           Summary: attribute packed fails to reduce char vector member
                    alignment
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

>From the following discussion: https://gcc.gnu.org/ml/gcc/2019-04/msg00030.html

The following test case shows that GCC fails to reduce the alignment of a char
vector member.  Clang and ICC succeed and return the expected values from the
two functions (1088 and 64, respectively).

$ cat z.c && gcc -c -O2 -Wall -fdump-tree-optimized=/dev/stdout z.c
struct S
{
  char c;
  __attribute__ ((aligned (64), packed, vector_size (1024))) char v;
};

int f (void) { return sizeof (struct S); }
int g (void) { return __alignof__ (struct S); }

z.c:4:3: warning: ‘packed’ attribute ignored for field of type ‘char’
[-Wattributes]
    4 |   __attribute__ ((aligned (64), packed, vector_size (1024))) char v;
      |   ^~~~~~~~~~~~~

;; Function f (f, funcdef_no=0, decl_uid=1909, cgraph_uid=1, symbol_order=0)

f ()
{
  <bb 2> [local count: 1073741824]:
  return 2048;   ;; Expected 1088

}



;; Function g (g, funcdef_no=1, decl_uid=1912, cgraph_uid=2, symbol_order=1)

g ()
{
  <bb 2> [local count: 1073741824]:
  return 1024;   ;; Expected 64

}

Reply via email to