https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78180
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|middle-end |tree-optimization --- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- r.idx_ is not optimized away inside the loop for some reason. NonWorking case: _53 = r.idx_; _54 = (long unsigned int) _53; MEM[(value_type &)&r][_54] = _2; Working case: _52 = r.idx_; r.times_[_52] = _2; std::array operator[]: _5 = &MEM[(const long int[128] &)this_2(D)][__n_4(D)]; ---------- reference operator[](size_type __n) noexcept { return _AT_Type::_S_ref(_M_elems, __n); } static constexpr _Tp& _S_ref(const _Type& __t, std::size_t __n) noexcept { return const_cast<_Tp&>(__t[__n]); } So SRA is not understanding the array being the first field .....