From Bugzilla Helper: User-Agent: Mozilla/5.0 (compatible; Konqueror/3.1; Linux) Description of problem: Hi, I tried compiling CVS HEAD for kde, but Qt (from qt-copy) already fails running designer. I made a small test case of an hang I found: #include <iostream> #include <qvaluelist.h> struct Data { int x; }; int main(int argc, char**) { QValueList<Data> mylist; Data data; QValueList<Data>::iterator it = mylist.append(data); (*it).x = (argc > 1 ? argc : 0); std::cout << (*it).x << std::endl; } g++ -O2 myvaluelist.cpp -o myvaluelist -I$QTDIR/include -L$QTDIR/lib -lqt-mt This little program works w/o arguments, but hangs w/ an arg. W/o -O2, it works. (installation is severn from 25 sept, gcc-3.3.1-5) Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. compile and run the above 2. 3. Additional info:
I replicated this on Fedora Core beta 2 by just compiling the above sample. gdb seemed to indicate it was hanging at line 110 of qvaluelist.h: T& operator*() { return node->data; }
Hmm, it's beta software, which Red Hat doses not support. Please report this bug to trolltech or kde developers. Please tell them which gcc version you use. Thanks
Imo it's a gcc optimization bug. (*it).x = (argc > 1 ? argc : 0) It hang if it assigns the if part (argc) and not if it assign the else part (0). How can that be Qt fault? Btw, Paul Nasrat suggest it's reproducable with the severn's include Qt.
Ok, made another testcase without qt this time, maybe that helps.. #include <iostream> struct Data { int x; }; template <class T> struct Wrapper { Wrapper(Data & d) : data (d) {} Data & operator * () { return data; } Data & data; }; int main(int argc, char**) { Data data; Wrapper<Data> mywrapper(data); (*mywrapper).x = (argc > 1 ? argc : 0); std::cout << (*mywrapper).x << std::endl; } Compile as 'g++ myvaluelist.cpp -o myvaluelist -O2' and it hangs if run with an argument. I've compiled it also with gcc-3.3.1 on an old RH-7.1 system: $ gcc -v Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/specs Configured with: ../gcc-3.3.1/configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --enable-threads --disable-nls : (reconfigured) ../gcc-3.3.1/configure --prefix=/usr --infodir=/usr/share/info --mandir=/ usr/share/man --enable-shared --enable-threads --disable-nls --enable-languages=c++,f77 Thread model: posix gcc version 3.3.1 And there isn't a hang.
Hmm, I got this hang reproduced so soon, that I forgot to reread the code :). Apprently it has nothing to do with templates but with operator *() returning a reference. #include <iostream> struct Data { int x; }; struct Wrapper { Wrapper() {} Data & operator * () { return data; } Data data; }; int main(int argc, char**) { Wrapper mywrapper; (*mywrapper).x = (argc > 1 ? argc : 0); std::cout << (*mywrapper).x << std::endl; }
http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00065.html
it's now fixed in gcc-3.3.1-6, which will be available in rawhide soon. Thanks for your report.