[Bug c++/69250] New: __attribute__ ((aligned(32))) not honored in classes

tkoenig at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 12 16:35:00 GMT 2016


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

            Bug ID: 69250
           Summary: __attribute__ ((aligned(32))) not honored in classes
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkoenig at gcc dot gnu.org
  Target Milestone: ---

32-byte alignment (useful for avx) breaks when used in classes.
This is for 5.3 on x86_64-unknown-cygwin.

Test case:

#include <iostream>

#define ALIGN  __attribute__ ((aligned(32)))

class Foo
{
public:
  int a;

  double x[24] ALIGN;
  int b;
} ALIGN;


int main()
{
  for (int i=0; i<5; i++)
    {
      Foo *p;
      double *a;
      p = new Foo;
      a = new double;
      unsigned long pv;
      pv = (unsigned long) p->x;
      if (pv % 32 != 0)
        std::cout << "pv = " << pv << " is not divisble by 32" <<
          " remainder is " << pv%32 << "\n";
      else
        std::cout << "pv = " << pv << " is divisble by 32\n";
    }
}

Output:

pv = 25769945392 is not divisble by 32 remainder is 16
pv = 25770175232 is divisble by 32
pv = 25770175536 is not divisble by 32 remainder is 16
pv = 25770175840 is divisble by 32
pv = 25770176144 is not divisble by 32 remainder is 16

This is closely related to PR 65122, but IMHO not exactly a dup.


More information about the Gcc-bugs mailing list