public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jamagallon@able.es
To: gcc-gnats@gcc.gnu.org
Cc: magallon@unizar.es
Subject: c++/10179: alignment attributes are not inherited correctly with empty classes
Date: Fri, 21 Mar 2003 11:46:00 -0000	[thread overview]
Message-ID: <20030321113903.27853.qmail@sources.redhat.com> (raw)


>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:


                 reply	other threads:[~2003-03-21 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030321113903.27853.qmail@sources.redhat.com \
    --to=jamagallon@able.es \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=magallon@unizar.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).