This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On alignment
- From: Nicola Pero <nicola at brainstorm dot co dot uk>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Andrew Haley <aph at redhat dot com>, Robert Dewar <dewar at gnat dot com>, <nathan at codesourcery dot com>, <shebs at apple dot com>, <gcc at gcc dot gnu dot org>
- Date: Tue, 22 Apr 2003 17:04:38 +0100 (BST)
- Subject: Re: On alignment
> > > > That packing rule is part of the i86 psABI
> > >
> > > It's still mighty odd, and of course in Ada you have to override this rule
> > > since it conflicts with the Ada standard, which requires that the default
> > > minimum alignment of a composite be not less than the alignment of any
> > > component.
> >
> > It's pretty weird in C++.
>
> It's the same in C. Weird or not, that's what the SVR4 psABI says, so
> that's what we do.
I suspect this is not just weird, but it would have consequences for
Objective-C.
The ObjC runtime library is supposed to be able to compute alignments in
structures at runtime (for various tasks, like encoding / decoding /
forwarding).
At runtime, the ObjC runtime library has information about the struct -
the type of each member. At the moment, it loops on the struct members,
and uses __alignof__ on each of them to get the alignment of that member
inside the struct (then, can read/write the struct members). As far as I
understand from this discussion, this doesn't work any longer.
For a typical example, look at libobjc/archive.c, functions
objc_write_type() and objc_read_type().
Assuming that we have to live with this weird ABI thing, what alternative
is there in order to compute alignments inside structs at runtime ?
In other words, how can objc_write_type() and objc_read_type() be
fixed/rewritten in order to work with the weird/unsane ABI thing ?
I don't have time to spend on this issue at the moment, but I thought I'd
raise the issue since it seems you're not aware of it. I can provide
testcases for objc_write_type() and objc_read_type() if needed.