https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105470
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #5) > GCC even tells you exactly how to fix the code. > > Here's the GCC error reformatted to make it a bit easier to read: > > error: loop variable it of type > const std::pair<Scintilla::Internal::KeyModifiers, Scintilla::Message>& > binds to a temporary constructed from type > const std::pair<const Scintilla::Internal::KeyModifiers, Scintilla::Message> > [-Werror=range-loop-construct] > > note: use non-reference type > const std::pair<Scintilla::Internal::KeyModifiers, Scintilla::Message> > to make the copy explicit or > const std::pair<const Scintilla::Internal::KeyModifiers, Scintilla::Message>& > to prevent copying > > cc1plus: all warnings being treated as errors auto comes in handy here so you could also just do: for ( const auto &it : sqt->kmap.GetKeyMap() ) And not worry about the type matches exactly.