On Wed, 28 Oct 2015, Bernd Schmidt wrote: > On 10/28/2015 07:06 PM, Alexander Monakov wrote: > > On Wed, 28 Oct 2015, Bernd Schmidt wrote: > > > Ok, so adjust the if condition for non-integral types - make it false if > > > the > > > size of the struct is smaller than the pointer type. > > > > I'm afraid it's an insufficient fix: it would remain broken for size-12 > > structs (containing 3 int fields, for example): they would be emitted with > > size 16 instead. > > Maybe check TYPE_ or DECL_ALIGN as well then. But I think in general the > problem cannot be avoided, let's say if you have a size-12 struct with a > pointer field.
Only packed structs might have their size indivisible by pointer size while containing a pointer field, so the problematic category is narrow. Packed structs aside, checking alignment doesn't bring new information: size will be divisible by alignment. Anything wrong with the simple fix: pick an integer type with the largest size dividing the original struct type size? Alexander