Bug 105784

Summary: Compiling kde/qt from CVS hangs on QValueList
Product: [Fedora] Fedora Reporter: Koos <koos.vriezen>
Component: gccAssignee: Than Ngo <than>
Status: CLOSED RAWHIDE QA Contact: Ben Levenson <benl>
Severity: high Docs Contact:
Priority: medium    
Version: rawhideCC: nobody+pnasrat
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-10-02 09:48:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Koos 2003-09-27 14:31:30 UTC
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:

Comment 1 Paul Nasrat 2003-09-27 14:36:47 UTC
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; }


Comment 2 Than Ngo 2003-09-29 13:48:23 UTC
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

Comment 3 Koos 2003-09-29 13:57:42 UTC
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. 
 

Comment 4 Koos 2003-09-29 17:41:58 UTC
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. 

Comment 5 Koos 2003-09-29 21:31:48 UTC
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; 
} 

Comment 8 Than Ngo 2003-10-02 09:48:36 UTC
it's now fixed in gcc-3.3.1-6, which will be available in rawhide soon. Thanks
for your report.