https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70434
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 38128 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38128&action=edit patch I am testing the attached. Note that we still miss folding the array ref to a bit-field-ref in case the index gets constant somewhen during optimization (if we'd have that we could unconditionally use the alternate lowering form). It still passes the testcases from the other PR (obviously as that doesn't use variable indices..., changing it to variable indices makes it pass as well but it doesn't seem to need the NON_LVALUE_EXPR for that) and it generates the same code with and without the cast.