[Bug c++/105470] New: ranged for loop whitespace parsing

roland at logikalsolutions dot com gcc-bugzilla@gcc.gnu.org
Tue May 3 23:28:23 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105470

            Bug ID: 105470
           Summary: ranged for loop whitespace parsing
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roland at logikalsolutions dot com
  Target Milestone: ---

I have this library 

https://sourceforge.net/u/roland_hughes/csscintilla/ci/default/tree/

On Ubuntu 20.04 it builds clean.

roland@roland-HP-EliteDesk-800-G2-SFF:/$ gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


On Ubuntu 22.04 it does not.

roland@roland-u22-04-VirtualBox:~/sf_projects/roland_hughes-csscintilla/copperspice$
gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Fresh build directory established
[37/39] Building CXX object
src/CMakeFiles/CsScintilla.dir/__/CsScintillaEditBase/CsScintillaEditBase.cpp.o
FAILED:
src/CMakeFiles/CsScintilla.dir/__/CsScintillaEditBase/CsScintillaEditBase.cpp.o 
/usr/bin/c++ -DBUILD_DATE=\"05/03/2022\" -DCsScintilla_EXPORTS
-I/home/roland/sf_projects/csscintilla_build/src
-I/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/src
-I/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/../include
-I/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/../src
-I/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/CsScintillaEditBase
-I/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/CsScintillaEdit
-isystem /usr/lib/cs_lib/include -isystem /usr/lib/cs_lib/include/QtCore
-isystem /usr/lib/cs_lib/include/QtGui -O3 -DNDEBUG -fPIC -DSCINTILLA_CS
-DMAKING_LIBRARY=1 -DSCI_LEXER=1 -D_CRT_SECURE_NO_DEPRECATE=1 -DNDEBUG=1 -Wall
-Wextra -Wuninitialized -pedantic -Werror -std=gnu++17 -MD -MT
src/CMakeFiles/CsScintilla.dir/__/CsScintillaEditBase/CsScintillaEditBase.cpp.o
-MF
src/CMakeFiles/CsScintilla.dir/__/CsScintillaEditBase/CsScintillaEditBase.cpp.o.d
-o
src/CMakeFiles/CsScintilla.dir/__/CsScintillaEditBase/CsScintillaEditBase.cpp.o
-c
/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp
/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:
In member function QString CsScintillaEditBase::keyMapText(int):
/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1034:62:
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]
 1034 |     for ( const std::pair<KeyModifiers, Scintilla::Message> &it :
sqt->kmap.GetKeyMap() )
      |                                                              ^~
/home/roland/sf_projects/roland_hughes-csscintilla/copperspice/CsScintillaEditBase/CsScintillaEditBase.cpp:1034:62:
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
ninja: build stopped: subcommand failed.


If you look at the error message, this version of the compiler demands the & be
against > instead of out with the variable.

This appears to be a whitespace parsing bug.


More information about the Gcc-bugs mailing list