From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2B0BE3857371; Wed, 4 May 2022 14:40:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B0BE3857371 From: "roland at logikalsolutions dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105470] ranged for loop whitespace parsing Date: Wed, 04 May 2022 14:40:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: roland at logikalsolutions dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2022 14:40:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105470 --- Comment #10 from Roland Hughes --- (In reply to Marek Polacek from comment #1) >=20 > The warning is completely correct, and the code should be fixed. >=20 > for ( const std::pair &it : someMap ) >=20 > This iterates over a map, with values of type: >=20 > std::pair >=20 No, it doesn't. [code] roland@roland-HP-EliteDesk-800-G2-SFF:~/sf_projects/roland_hughes-csscintil= la$ grep -irn GetKeyMap * copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1031: // the fact GetKeyMap() returns const means we can't use an iterator copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1034: for ( const std::pair &it : sqt->kmap.GetKeyMap() ) copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1059: auto findResult =3D std::find_if( std::begin( sqt->kmap.GetKeyMap() ), copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1060:=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 std::end( sqt->kmap.GetKeyMap() ), copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1066: if ( findResult !=3D std::end( sqt->kmap.GetKeyMap() ) ) copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:4314:const std::map &CsScintillaEditBase::GetKeyMap() const noexcept copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:4316: return sqt->kmap.GetKeyMap(); copperspice/CsScintillaEditBase/CsScintillaEditBase.h:79: const std::map &GetKeyMap() const noexcept; src/KeyMap.h:60: const std::map &GetKeyMap() const noexcept; src/KeyMap.cxx:50:const std::map &KeyMap::GetKeyMap() const noexcept { [/code] There is no definition of that map anywhere in the codebase where KeyModifi= ers is declared const. The method being called returns a const & to the entire map, but there is no const declared within the map.=