gcc doesn't like foreach with const-ref containers

Andreas Pakulat apaku at gmx.de
Tue Sep 4 23:39:45 CEST 2007


Hi,

while compiling kdevelop I got an error on some code in its language
support which compiles fine with gcc 4.2 on linux. (I'm using mingw
suite 5.1.3, i.e. gcc 3.4.5 on win32).

The problem seems to be that findDeclarationsInternal on line 107 in
kdevelop/languages/cpp/duchainbuilder/cppducontext.h has a
const-reference to a QList as parameter. The error (log attached)
indicates that foreach() can't handle such a const-ref list, while doing
the "standard" for( foo::const_iterator it = list.begin()... thing works
fine.

Does anybody know a "better" solution than to use an iterator-loop, or a
reason why this is. Is it maybe a gcc bug?

Andreas

-- 
Be careful!  UGLY strikes 9 out of 10!
-------------- next part --------------
D:\andreas\win32libs\bin\cmake.exe -HD:\andreas\kde4\sources\kdevelop -BD:\andreas\kde4\sources\kdevelop\build --check-build-system CMakeFiles\Makefile.cmake 0
Dependee "D:/andreas/kde4/install/include/kdevplatform/util/envselectwidget.h" does not exist for depender "buildtools/builders/makebuilder/CMakeFiles/kcm_kdev_makebuilder.dir/makebuilderpreferences.obj".
Clearing dependencies in "buildtools/builders/makebuilder/CMakeFiles/kcm_kdev_makebuilder.dir/depend.make".
Clearing dependencies in "buildtools/builders/makebuilder/CMakeFiles/kcm_kdev_makebuilder.dir/depend.internal".
Dependee "D:/andreas/kde4/install/include/kdevplatform/util/envwidget.h" does not exist for depender "buildtools/builders/makebuilder/CMakeFiles/kdevmakebuilder.dir/makebuilder.obj".
Clearing dependencies in "buildtools/builders/makebuilder/CMakeFiles/kdevmakebuilder.dir/depend.make".
Clearing dependencies in "buildtools/builders/makebuilder/CMakeFiles/kdevmakebuilder.dir/depend.internal".
D:\andreas\win32libs\bin\cmake.exe -E cmake_progress_start D:\andreas\kde4\sources\kdevelop\build\CMakeFiles 37
mingw32-make -f CMakeFiles/Makefile2 all
mingw32-make[1]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make -f src/CMakeFiles/kdevelop.dir/build.make src/CMakeFiles/kdevelop.dir/depend
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `src/CMakeFiles/kdevelop.dir/depend'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make -f src/CMakeFiles/kdevelop.dir/build.make src/CMakeFiles/kdevelop.dir/build
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `src/CMakeFiles/kdevelop.dir/build'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
D:\andreas\win32libs\bin\cmake.exe -E cmake_progress_report D:\andreas\kde4\sources\kdevelop\build\CMakeFiles  1
[  2%] Built target kdevelop
mingw32-make -f languages/cpp/CMakeFiles/kdev_includepathresolver.dir/build.make languages/cpp/CMakeFiles/kdev_includepathresolver.dir/depend
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/CMakeFiles/kdev_includepathresolver.dir/depend'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make -f languages/cpp/CMakeFiles/kdev_includepathresolver.dir/build.make languages/cpp/CMakeFiles/kdev_includepathresolver.dir/build
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/CMakeFiles/kdev_includepathresolver.dir/build'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
D:\andreas\win32libs\bin\cmake.exe -E cmake_progress_report D:\andreas\kde4\sources\kdevelop\build\CMakeFiles 
[  2%] Built target kdev_includepathresolver
mingw32-make -f languages/cpp/parser/rpp/CMakeFiles/kdev4cpprpp.dir/build.make languages/cpp/parser/rpp/CMakeFiles/kdev4cpprpp.dir/depend
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/parser/rpp/CMakeFiles/kdev4cpprpp.dir/depend'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make -f languages/cpp/parser/rpp/CMakeFiles/kdev4cpprpp.dir/build.make languages/cpp/parser/rpp/CMakeFiles/kdev4cpprpp.dir/build
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/parser/rpp/CMakeFiles/kdev4cpprpp.dir/build'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
D:\andreas\win32libs\bin\cmake.exe -E cmake_progress_report D:\andreas\kde4\sources\kdevelop\build\CMakeFiles  9 10
[  8%] Built target kdev4cpprpp
mingw32-make -f languages/cpp/parser/CMakeFiles/kdev4cppparser.dir/build.make languages/cpp/parser/CMakeFiles/kdev4cppparser.dir/depend
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/parser/CMakeFiles/kdev4cppparser.dir/depend'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make -f languages/cpp/parser/CMakeFiles/kdev4cppparser.dir/build.make languages/cpp/parser/CMakeFiles/kdev4cppparser.dir/build
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/parser/CMakeFiles/kdev4cppparser.dir/build'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
D:\andreas\win32libs\bin\cmake.exe -E cmake_progress_report D:\andreas\kde4\sources\kdevelop\build\CMakeFiles  5 6 7 8
[ 18%] Built target kdev4cppparser
mingw32-make -f languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/build.make languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/depend
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[2]: Nothing to be done for `languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/depend'.
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make -f languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/build.make languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/build
mingw32-make[2]: Entering directory `D:/andreas/kde4/sources/kdevelop/build'
D:\andreas\win32libs\bin\cmake.exe -E cmake_progress_report D:\andreas\kde4\sources\kdevelop\build\CMakeFiles 
[ 18%] Building CXX object languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/contextbuilder.obj
D:\andreas\mingw\bin\g++.exe   -DMAKE_KDEV4CPPDUCHAINBUILDER_LIB   -g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline -ID:\andreas\kde4\sources\kdevelop\build\languages\cpp\duchainbuilder -ID:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder -ID:\andreas\kde4\sources\kdevelop -ID:\andreas\kde4\sources\kdevelop\build -ID:\andreas\kde4\sources\kdevelop\languages\cpp -ID:\andreas\kde4\sources\kdevelop\languages\cpp\parser -ID:\andreas\kde4\sources\kdevelop\languages\cpp\expressionparser -ID:\andreas\kde4\sources\qt-copy\include -ID:\andreas\kde4\sources\qt-copy\include\Qt -ID:\andreas\kde4\sources\qt-copy\mkspecs\default -ID:\andreas\kde4\sources\qt-copy\include\QtCore -ID:\andreas\kde4\sources\qt-copy\include\QtGui -ID:\andreas\kde4\sources\qt-copy\include\Qt3Support -ID:\andreas\kde4\sources\qt-copy\include\QtAssistant -ID:\andreas\kde4\sources\qt-copy\include\QtDesigner -ID:\andreas\kde4\sources\qt-copy\include\QtNetwork -ID:\andreas\kde4\sources\qt-copy\include\QtOpenGL -ID:\andreas\kde4\sources\qt-copy\include\QtSql -ID:\andreas\kde4\sources\qt-copy\include\QtXml -ID:\andreas\kde4\sources\qt-copy\include\QtSvg -ID:\andreas\kde4\sources\qt-copy\include\QtScript -ID:\andreas\kde4\sources\qt-copy\include\QtUiTools -ID:\andreas\kde4\sources\qt-copy\include\QtTest -ID:\andreas\kde4\sources\qt-copy\include\QtDBus -ID:\andreas\kde4\install\include -ID:\andreas\kde4\install\include\KDE -ID:\andreas\kde4\install\include\mingw -ID:\andreas\kde4\install\include\threadweaver -ID:\andreas\kde4\install\include\kdevplatform\interfaces -ID:\andreas\kde4\install\include\kdevplatform\editor -ID:\andreas\kde4\install\include\kdevplatform\project -ID:\andreas\kde4\install\include\kdevplatform\project\interfaces -ID:\andreas\kde4\install\include\kdevplatform\language -ID:\andreas\kde4\install\include\kdevplatform\language\interfaces -ID:\andreas\kde4\install\include\kdevplatform\language\backgroundparser -ID:\andreas\kde4\install\include\kdevplatform\language\duchain -ID:\andreas\kde4\install\include\kdevplatform\language\duchain\viewer   -DQT_DLL -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -D_REENTRANT -DKDE_DEPRECATED_WARNINGS -DHAVE_CONFIG_H=1 -o languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/contextbuilder.obj -c D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\contextbuilder.cpp
In file included from D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\contextbuilder.h:27,
                 from D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\contextbuilder.cpp:21:
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h: In instantiation of `QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>':
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116:   instantiated from here
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1816: error: forming reference to reference type `const QList<KDevelop::QualifiedIdentifier>&'
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1819: error: `const QList<KDevelop::QualifiedIdentifier>&' is not a class, struct, or union type
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1819: error: `const QList<KDevelop::QualifiedIdentifier>&' is not a class, struct, or union type
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h: In member function `virtual void Cpp::CppDUContext<Base>::findDeclarationsInternal(const QList<KDevelop::QualifiedIdentifier>&, const KTextEditor::Cursor&, const KSharedPtr<KDevelop::AbstractType>&, QList<KDevelop::Declaration*>&, typename BaseContext::SearchFlags) const':
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116: error: 'class QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>' has no member named 'i'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116: error: 'class QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>' has no member named 'e'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116: error: 'class QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>' has no member named 'i'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116: error: 'class QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>' has no member named 'i'
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h: At global scope:
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h: In instantiation of `QForeachContainer<const QList<Cpp::ExpressionEvaluationResult>&>':
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:334:   instantiated from here
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1819: error: `const QList<Cpp::ExpressionEvaluationResult>&' is not a class, struct, or union type
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1819: error: `const QList<Cpp::ExpressionEvaluationResult>&' is not a class, struct, or union type
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h: In member function `void Cpp::CppDUContext<Base>::setInstantiatedFrom(Cpp::CppDUContext<Base>*, const QList<Cpp::ExpressionEvaluationResult>&)':
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:334: error: 'class QForeachContainer<const QList<Cpp::ExpressionEvaluationResult>&>' has no member named 'i'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:334: error: 'class QForeachContainer<const QList<Cpp::ExpressionEvaluationResult>&>' has no member named 'e'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:334: error: 'class QForeachContainer<const QList<Cpp::ExpressionEvaluationResult>&>' has no member named 'i'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:334: error: 'class QForeachContainer<const QList<Cpp::ExpressionEvaluationResult>&>' has no member named 'i'
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h: In member function `void Cpp::CppDUContext<Base>::findDeclarationsInternal(const QList<KDevelop::QualifiedIdentifier>&, const KTextEditor::Cursor&, const KSharedPtr<KDevelop::AbstractType>&, QList<KDevelop::Declaration*>&, typename BaseContext::SearchFlags) const [with BaseContext = KDevelop::DUContext]':
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\contextbuilder.cpp:794:   instantiated from here
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116: error: no matching function for call to `QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>::QForeachContainer(const QList<KDevelop::QualifiedIdentifier>&)'
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1814: note: candidates are: QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>::QForeachContainer(const QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>&)
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h: In member function `void Cpp::CppDUContext<Base>::findDeclarationsInternal(const QList<KDevelop::QualifiedIdentifier>&, const KTextEditor::Cursor&, const KSharedPtr<KDevelop::AbstractType>&, QList<KDevelop::Declaration*>&, typename BaseContext::SearchFlags) const [with BaseContext = KDevelop::TopDUContext]':
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\contextbuilder.cpp:794:   instantiated from here
D:\andreas\kde4\sources\kdevelop\languages\cpp\duchainbuilder\cppducontext.h:116: error: no matching function for call to `QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>::QForeachContainer(const QList<KDevelop::QualifiedIdentifier>&)'
D:/andreas/kde4/sources/qt-copy/include/QtCore/../../src/corelib/global/qglobal.h:1814: note: candidates are: QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>::QForeachContainer(const QForeachContainer<const QList<KDevelop::QualifiedIdentifier>&>&)
mingw32-make[2]: *** [languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/contextbuilder.obj] Error 1
mingw32-make[2]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make[1]: *** [languages/cpp/duchainbuilder/CMakeFiles/kdev4cppduchainbuilder.dir/all] Error 2
mingw32-make[1]: Leaving directory `D:/andreas/kde4/sources/kdevelop/build'
mingw32-make: *** [all] Error 2


More information about the Kde-windows mailing list