On Fri, Jun 27, 2025 at 02:00:26PM +0200, Richard Biener wrote:
> > +  gcc_assert (RECORD_OR_UNION_TYPE_P (container));
> > +
> > +  for (tree t = TYPE_FIELDS (container); t; t = DECL_CHAIN (t))
> > +    {
> > +      if (TREE_CODE (t) != FIELD_DECL)
> > +    continue;
> > +
> > +      tree byte_offset = DECL_FIELD_OFFSET (t);
> > +      if (TREE_CODE (byte_offset) != INTEGER_CST
> > +      || tree_int_cst_lt (offset, byte_offset))
> > +    return false;
> > +
> > +      tree bit_offset = size_int (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (t))
> > +                  / BITS_PER_UNIT);
> 
> That math seems to be wrong for actual bit offsets.  I’d suggest to skip the 
> field if it isn’t a multiple of BITS_PER_UNIT
> 
> > +      byte_offset = size_binop (PLUS_EXPR, byte_offset, bit_offset);
> 
> it would be nice to avoid tree arithmetic here as well by using wide_int.

Or just use byte_position?  That doesn't avoid tree arith, on the other side
is used everywhere.

        Jakub

Reply via email to