PR 17949 (unaligned memory accesses due to ivopts) question

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Sat Oct 16 21:29:00 GMT 2004


Hello,

strength reduction in ivopts may turn references to "packed" fields
in structures to accesses via pointers.  The adress obtained this
way may be unaligned, which causes crash when STRICT_ALIGNMENT = 1.

This problem however does not seem to be limited to ivopts.  For example
the testcase below probably (I do not have access to the hardware
just now, so I have checked only assembler, and I cannot read ia64 asm
very well, so I am not entirely sure) fails in the same way.

It seems to me that fixing this in ivopts is not the right place.
Maybe setting DECL_NONADDRESSABLE_P for unaligned fields of structures
when STRICT_ALIGNMENT = 1 would be more correct?

Zdenek

typedef struct
{
  short i __attribute__ ((packed));
  int f[2] __attribute__ ((packed));
} A;

A a;

void foo(int *);

int main(void)
{
  foo (a.f);
  return 0;
}

void foo(int *x)
{
  *x = 0;
}



More information about the Gcc mailing list