Andrew Stubbs <andrew.stu...@linaro.org> wrote on 21.02.2012 11:56:07:

> I'm not sure, but I believe that the compiler requires (prefers) any
> structs that you want included inside packed structs to be themselves
> packed, so you can end up with some structs with apparently unnecessary
> attributes on them.

I don't see why the compiler would care.  Its just that if an inner
struct already has padding somewhere, this padding doesn't go away
(the struct layout is not recomputed) just because it is embedded
in a larger struct which is marked packed.  [Marking the outer struct
packed will still affect the overall alignment requirement of the
inner struct; it just won't affect it inner layout.]

> It might also have an effect when you place the struct inside an
> unpacked struct?

Yes, of course: if the struct is packed, then the struct as a whole
has an alignment requirement of 1, which may affect the placement of
the struct as an element within an outside (unpacked) struct.

> Without context I've no idea whether that's what's going on here. Of
> course, a no-op "packed" attribute ought to be harmless...

It is not really "no-op": it reduces the alignment requirement of
the struct from 2 (in this case) to 1, which is actually exactly
what's causing the problems in the original test case.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU compiler and toolchain for Linux on System z and Cell/B.E.
  IBM Deutschland Research & Development GmbH
  Vorsitzende des Aufsichtsrats: Martina Koederitz | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294


_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to