https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88739
--- Comment #45 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > So to get back to this - my thinking was that for a reference REF I can do > > base = get_inner_reference (ref, &bitsize, &bitpos, &offset, &mode, > &unsignedp, &reversep, &volatilep); > > and get the semantically same REF building > > REF' = BIT_FIELD_REF<*(&base + offset), bitsize, bitpos> > > (plus setting REF_REVERSE_STORAGE_ORDER and TREE_THIS_VOLATILE on REF'). > > This appearantly breaks down (similarly for get_ref_base_and_extent) for > bigendian and DECL_BIT_FIELD outer COMPONENT_REFs. And maybe for more? > > Is my expectation that the above "works" flawed? So "bit position" > and "position of the first referenced bit" are two separate things? No, they are the same, but I think that BIT_FIELD_REF is not supposed to be itself applied to a bit-field, as in the case at hand, since it's precisely meant to designate a bit-field. In other words, the above base cannot be a bit-field. So the safest route is probably to forbid such an abomination, i.e. to make sure that the first argument of BIT_FIELD_REF is a bona-fide base type.