This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: On alignment


>>>>> "Jason" == Jason Merrill <jason at redhat dot com> writes:

[ about  struct foo { double x; } ]

Tom> I'd like to find the most future-proof way to do this.  In the above,
Tom> is __alignof__(foo::x) the best way?  I'm only concerned with
Tom> alignment of fields.

Jason> It is since my recent patch to do all alignment calculation for
Jason> fields in layout_decl.

I can't do this.

    struct aligner { double field; };

    int compute () { return __alignof__ (aligner::field); }

fleche. gcc -c y.cc
y.cc: In function `int compute()':
y.cc:1: error: invalid use of non-static data member `aligner::field'
y.cc:3: error: from this location


I can use __alignof__(aligner), but my concern is that eventually this
will yield "8" instead of "4" on x86.  libgcj really needs to know the
alignment required in structures, for compatibility with the compiler.
Preferably we'd have the compiler tell us this info.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]