gcc doesn't like foreach with const-ref containers

Jarosław Staniek js at iidea.pl
Wed Sep 5 19:31:47 CEST 2007


Andreas Pakulat said the following, On 2007-09-05 19:17:
> On 05.09.07 06:30:19, Christian Ehrlicher wrote:
>> Andreas Pakulat schrieb:
>>> 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?
>> Plz make a testcase for this so I can take a look
> 
> Seems like templates have to be involved as well. See the attached
> main.cpp (just use qmake -project;qmake;make to build).
> 
> As soon as you remove the template from MyTest it compiles fine. Else I
> get that error.

Do msvc like it, BTW? Just today I have noticed this is inconvenient.

-- 
regards / pozdrawiam, Jaroslaw Staniek
  Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
  Kexi & KOffice: http://www.kexi.pl/en, http://www.koffice.org
  KDE3 & KDE4 Libraries for MS Windows: http://kdelibs.com, http://www.kde.org



More information about the Kde-windows mailing list