This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10179: alignment attributes are not inherited correctly with empty classes
- From: jamagallon at able dot es
- To: gcc-gnats at gcc dot gnu dot org
- Cc: magallon at unizar dot es
- Date: 21 Mar 2003 11:39:03 -0000
- Subject: c++/10179: alignment attributes are not inherited correctly with empty classes
- Reply-to: jamagallon at able dot es
>Number: 10179
>Category: c++
>Synopsis: alignment attributes are not inherited correctly with empty classes
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 21 11:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: jamagallon at able dot es
>Release: gcc-3.2.2
>Organization:
>Environment:
Linux Mandrake 9.1
>Description:
__attribute__((__aligned__(16))) is applied to an empty base class, used just to propagate that and new/delete operators, not defined in the example (do you remember SSE...).
If derived class T is smaller than the alignment, it is obeyed so arrays of T give aligned alements. If size of T is bigger that alignment, elements in T[] are unaligned. If base is not empty, it works ok. Is this expected behaviour ?
>How-To-Repeat:
#include <iostream>
using namespace std;
#define __class class __attribute__((__aligned__(16)))
__class A
{
public:
void id() { cout << this << endl; };
};
class T : public A
{
public:
// with 3 floats, sizeof(T)==16
// with 5 floats, sizeof(T)==20
float f[5];
};
int main()
{
A a;
cout << "sizeof(A) = " << sizeof(A) << endl;
cout << &a << endl;
A aa[2];
cout << "sizeof(A[2]) = " << sizeof(aa) << endl;
cout << &aa[0] << endl;
cout << &aa[1] << endl;
T t;
cout << "sizeof(T) = " << sizeof(T) << endl;
cout << &t << endl;
T tt[2];
cout << "sizeof(T[2]) = " << sizeof(tt) << endl;
cout << &tt[0] << endl;
cout << &tt[1] << endl;
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: