This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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: ARM compiler misbehaves ?


On Thu, 2004-04-29 at 16:30, Grant Edwards wrote:
> On Thu, Apr 29, 2004 at 04:23:26PM +0100, Richard Earnshaw wrote:
> > On Thu, 2004-04-29 at 15:43, Bill Gatliff wrote:
> > 
> > > Manipulations through pointers won't work, that much should be clear by 
> > > now (as should be the underlying reason).  But _references_ to packed 
> > > structure members by name, even when misaligned, do work.  Gcc will 
> > > reconstruct the misaligned object in a properly-aligned one (a register, 
> > > or on the stack), when necessary.
> > 
> > Indeed.  There's no dispute about this.
> 
> Except that you said it didn't work in a previous post.

There seems to be some general confusion here.  The thing I was (trying)
to say doesn't work is placing the address of a packed object into a
pointer to an object of the same base type.  Hence

struct s {char a; short b;} __attribute__((packed));

struct s S;

short *p = &S.b;  

says that although S is a packed object, I'm now asserting that S.b is,
in fact, aligned as a short.

If it turns out that S.b wasn't aligned, then the code won't work,
because the compiler is entitled to assume that it was.

R.

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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