Subject: Re: Data Abort Exceptions
To: Ben Harris <bjh21@netbsd.org>
From: Richard Earnshaw <rearnsha@arm.com>
List: port-arm
Date: 07/23/2002 10:24:20
> On Mon, 22 Jul 2002, Jay Monkman wrote:
>
> > How can this work? What if someone wants to compile an application
> > something like the following:
> > typedef struct {
> > char c __attribute__ ((packed));
> > long l __attribute__ ((packed));
> > } foo_t;
> >
> >
> > void func1(void);
> > void func2(long *p);
> >
> > void func1(void)
> > {
> > foo_t foo;
> >
> > foo.c = 'a';
> > foo.l = 0x12345678;
> >
> > func2(&foo.l);
>
> I think GCC should issue a warning here. You're implicitly converting
> from one pointer type to another with stricter alignment constraints
> (actually not stricter so much as utterly incompatible here), which is
> often a mistake.
Indeed. Unfortunately GCC does not have a "packed long" type outside of a
structure, so it is practically impossible to write code like that above
and get it to work.
R.