public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/10179: alignment attributes are not inherited correctly with empty classes
@ 2003-03-21 11:46 jamagallon
0 siblings, 0 replies; only message in thread
From: jamagallon @ 2003-03-21 11:46 UTC (permalink / raw)
To: gcc-gnats; +Cc: magallon
>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@able.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:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-21 11:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-21 11:46 c++/10179: alignment attributes are not inherited correctly with empty classes jamagallon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).