This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On alignment
Tom Tromey <tromey at redhat dot com> writes:
[...]
| Gabriel> I think the template-based solution I posted in another
| Gabriel> message solves the problem...
|
| In that message you said that you got "8" as the answer for a double
| field on x86. That's not the answer I'm looking for :-(. On x86, a
| double field has alignment 4, while a non-field double has alignment
| 8.
Thank you for correcting me; it seems like I made two errors in my
previous post:
1) I took the __alignof__ of the field instead of the instance
2) I used a reference (I can't remember why I wrote that).
They are corrected now in this:
template<typename T>
struct object_alignment {
struct helper {
T datum;
helper();
};
static helper instance;
enum { value = __alignof__ (instance) };
};
and now, I get the expected answer (4). [I would appreciate you
double check]
Thanks,
-- Gaby