On Wed, Jan 25, 2023 at 06:22:56AM -0500, Siddhesh Poyarekar wrote: > On 2023-01-25 02:44, Richard Biener wrote: > > > t = TREE_OPERAND (expr, 1); > > > - off = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (t), > > > + off = size_binop (PLUS_EXPR, > > > + (TREE_OPERAND (expr, 2) ? TREE_OPERAND (expr, 2) > > > + : DECL_FIELD_OFFSET (t)), > > > > That isn't correct - operand 2 is the field offset in units of > > DECL_OFFSET_ALIGN (t) / BITS_PER_UNIT. > > See component_ref_filed_offset (), maybe you should be using that > > function instead? > > Ahh, and it passed my testing only because I was testing a char. Thanks, > I'll test and send an update with additional tests.
I think you want something like: struct S { char a[n]; unsigned long long b; int d; char e[2 * n]; } s; and test say bdos of &s.d, 0 and &s.e[n - 2], 0 Jakub