Bug 106274

Summary: filter_oe/filter_pmail compilation fails with gcc-3.2.x
Product: [Unmaintained] kmail Reporter: Rex Dieter <rdieter>
Component: kmailcvtAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: mefoster
Priority: NOR    
Version: 1.8.2   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: naive/quick-n-dirty fix

Description Rex Dieter 2005-05-25 16:07:59 UTC
Version:            (using KDE KDE 3.4.1)
Installed from:    RedHat RPMs
Compiler:          gcc-3.2.3 gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-49)
OS:                Linux

filter_oe/filter_pmail (as part of kdepim-3.4.1) compilation fails with gcc-3.2.x.  Tested with both gcc-3.2.3 on RedHat EL3 and gcc-3.2.2 on RedHat 9.  It built ok for me using gcc-3.4.3 on RedHat EL4.  Compiler error(s) were:

make[1]: Entering directory `/home/rdieter/BUILD/kdepim-3.4.1/kmailcvt'
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../libkdepim -I/usr/include/kde -I/usr/lib/qt-3.3/include -I/usr/X11R6/include   -DQT_THREAD_SUPPORT  -D_REENTRANT -D_FILE_OFFSET_BITS=64  -DNDEBUG -DNO_DEBUG -O2 -O2 -pipe -march=i386 -mcpu=i686 -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION  -MT filter_oe.o -MD -MP -MF ".deps/filter_oe.Tpo" \
  -c -o filter_oe.o `test -f 'filter_oe.cxx' || echo './'`filter_oe.cxx; \
then mv -f ".deps/filter_oe.Tpo" ".deps/filter_oe.Po"; \
else rm -f ".deps/filter_oe.Tpo"; exit 1; \
fi
filter_oe.cxx: In member function `QString FilterOE::getFolderName(QString)':
filter_oe.cxx:400: invalid initializer
make[1]: *** [filter_oe.o] Error 1

if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../libkdepim -I/usr/include/kde -I/usr/lib/qt-3.3/include -I/usr/X11R6/include   -DQT_THREAD_SUPPORT  -D_REENTRANT -D_FILE_OFFSET_BITS=64  -DNDEBUG -DNO_DEBUG -O2 -O2 -pipe -march=i386 -mcpu=i686 -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION  -MT filter_pmail.o -MD -MP -MF ".deps/filter_pmail.Tpo" \
  -c -o filter_pmail.o `test -f 'filter_pmail.cxx' || echo './'`filter_pmail.cxx; \
then mv -f ".deps/filter_pmail.Tpo" ".deps/filter_pmail.Po"; \
else rm -f ".deps/filter_pmail.Tpo"; exit 1; \
fi
filter_pmail.cxx: In member function `QString 
   FilterPMail::getFolderName(QString)':
filter_pmail.cxx:329: invalid initializer
make[1]: *** [filter_pmail.o] Error 1
Comment 1 Rex Dieter 2005-05-25 16:25:44 UTC
Created attachment 11195 [details]
naive/quick-n-dirty fix

replace 
QString tmp[x] = *it
with
QString tmp[x];
tmp = *it;

Produces compiler warning: ISO C++ forbids assignment of arrays
Comment 2 Danny Kukawka 2005-06-21 18:14:35 UTC
But this fix don't work with newer compiler versions, on gcc 3.3.5 this is a error and not a warning.
Comment 3 Rex Dieter 2005-06-22 05:41:03 UTC
I never said it was a correct fix, just that it allowed the compilation to continue w/gcc-3.2.x.  Do you have a better suggestion?
Comment 4 Rex Dieter 2005-06-22 05:41:27 UTC
I never said it was a correct fix, just that it allowed the compilation to continue w/gcc-3.2.x.  Do you have a better suggestion?
Comment 5 Danny Kukawka 2005-06-22 10:56:05 UTC
SVN commit 427876 by dkukawka:

* Applying slightly adopted patches by Adriaan de Groot <groot@kde.org>,
  fixing bug #106274
* changed some code documetation

BUG: 106274



 M  +7 -7      filter_oe.cxx  
 M  +10 -1     filter_oe.hxx  
 M  +2 -2      filter_pmail.cxx  
 M  +12 -2     filter_pmail.hxx  
 M  +52 -1     filters.hxx  
Comment 6 Rex Dieter 2005-07-21 21:02:11 UTC
Nope, not fixed, using gcc-3.2.3, RedHat Enterprise 3:

make[3]: Entering directory `/home/rdieter/BUILD/kdepim-3.4.2/kmailcvt'
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../libkdepim -I/usr/include/kde -I/usr/lib/qt-3.3/include -I/usr/X11R6/include   -DQT_THREAD_SUPPORT  -D_REENTRANT -D_FILE_OFFSET_BITS=64  -DNDEBUG -DNO_DEBUG -O2 -O2 -pipe -march=i386 -mcpu=i686 -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION  -MT kmailcvt.all_cxx.o -MD -MP -MF ".deps/kmailcvt.all_cxx.Tpo" \
  -c -o kmailcvt.all_cxx.o `test -f 'kmailcvt.all_cxx.cxx' || echo './'`kmailcvt.all_cxx.cxx; \
then mv -f ".deps/kmailcvt.all_cxx.Tpo" ".deps/kmailcvt.all_cxx.Po"; \
else rm -f ".deps/kmailcvt.all_cxx.Tpo"; exit 1; \
fi
In file included from kmailcvt.all_cxx.cxx:3:
filter_oe.cxx: In member function `QString FilterOE::getFolderName(QString)':
filter_oe.cxx:400: invalid initializer
In file included from kmailcvt.all_cxx.cxx:4:
filter_pmail.cxx: In member function `QString 
   FilterPMail::getFolderName(QString)':
filter_pmail.cxx:329: invalid initializer
make[3]: *** [kmailcvt.all_cxx.o] Error 1
make[3]: Leaving directory `/home/rdieter/BUILD/kdepim-3.4.2/kmailcvt'
Comment 7 Danny Kukawka 2005-07-21 21:33:06 UTC
o.k. I have forgotten to backport the patch to kde 3.4.2. Did you tried SVN_HEAD? Did this version works for you? 

I backport this tomorrow.
Comment 8 Rex Dieter 2005-07-21 21:36:40 UTC
I'm building kdepim-3.4.2 as released to packagers.
Comment 9 Danny Kukawka 2005-07-25 13:09:58 UTC
SVN commit 438561 by dkukawka:

- backport from trunk to prevent failure with older gcc (< gcc 3.3) 

BUG: 106274


 M  +5 -5      filter_oe.cxx  
 M  +10 -1     filter_oe.hxx  
 M  +2 -2      filter_pmail.cxx  
 M  +12 -2     filter_pmail.hxx  
 M  +52 -1     filters.hxx  


--- branches/KDE/3.4/kdepim/kmailcvt/filter_oe.cxx #438560:438561
@@ -389,15 +389,15 @@
 {
     bool found = false;
     bool foundFilename = false;
-    QString folder = "";
+    QString folder;
     // we must do this because folder with more than one upper letter
     // at start have maybe not a file named like the folder !!!
     QString search = filename.lower();
     
     while (!found)
     {
-        for ( QValueList<QString[4]>::Iterator it = folderStructure.begin(); it != folderStructure.end(); it++) {
-            QString tmp[4] = *it;
+        for ( FolderStructureIterator it = folderStructure.begin(); it != folderStructure.end(); it++) {
+            FolderStructure tmp = *it;
             if(foundFilename == false) {
                 QString _tmpFileName = tmp[1];
                 _tmpFileName = _tmpFileName.lower();
@@ -410,7 +410,7 @@
                 QString _currentID = tmp[2];
                 QString _parentID = tmp[3];
                 if(_currentID == search) {
-                    if(_parentID == "") { // this is the root of the folder
+                    if(_parentID.isEmpty()) { // this is the root of the folder
                         found = true;
                         break;
                     } else {
@@ -421,7 +421,7 @@
             }
         }
         // need to break the while loop maybe in some cases
-        if((foundFilename == false) && (folder == "")) return folder;
+        if((foundFilename == false) && (folder.isEmpty())) return folder;
     }
     return folder;
 }
--- branches/KDE/3.4/kdepim/kmailcvt/filter_oe.hxx #438560:438561
@@ -61,8 +61,17 @@
     bool parsedFolder;
     /** true if the current parsing file is the folder file */
     bool currentIsFolderFile;
+
+    /** Folder structure with following  4 entries:
+        1. descriptive folder name 
+        2. filename 
+        3. ID of current folder
+        4. ID of parent folder 
+    */
+    typedef FolderStructureBase<4> FolderStructure;
     /** matrix with information about the folder structure*/
-    QValueList<QString[4]> folderStructure;
+    QValueList<FolderStructure> folderStructure;
+    typedef QValueList<FolderStructure>::Iterator FolderStructureIterator;
 
     /** name of the current folder */
     QString folderName;
--- branches/KDE/3.4/kdepim/kmailcvt/filter_pmail.cxx #438560:438561
@@ -325,8 +325,8 @@
     
     while (!found)
     {
-        for ( QValueList<QString[5]>::Iterator it = folderMatrix.begin(); it != folderMatrix.end(); it++) {
-            QString tmp[5] = *it;
+        for ( FolderStructureIterator it = folderMatrix.begin(); it != folderMatrix.end(); it++) {
+            FolderStructure tmp = *it;
             
             QString _ID = tmp[2];
             if(_ID == search) {
--- branches/KDE/3.4/kdepim/kmailcvt/filter_pmail.hxx #438560:438561
@@ -50,8 +50,18 @@
     QDir dir;
     /**  pointer to the info */
     FilterInfo * inf;
-    /** QStringList with the foldernames, First String contains the ID, the second the folder */
-    QValueList<QString[5]> folderMatrix;
+
+    /** Folder structure here has 5 entries. */
+    typedef FolderStructureBase<5> FolderStructure;
+    /** List with the folder matrix, which contains following strings:
+	1. type (2 for root-folder, 1 for folder, 0 for mailarchiv)
+	2. type (1 for root-folder, 3 for folder, 0 for mailarchiv)  
+	3. "ID:flag:filename" of folder/archiv   
+	4. "ID:name" of parent folder
+	5. name of folder/archiv
+    */
+    QValueList<FolderStructure> folderMatrix;
+    typedef QValueList<FolderStructure>::Iterator FolderStructureIterator;
     
     /** true, if the folderfile is parsed **/
     bool folderParsed;
--- branches/KDE/3.4/kdepim/kmailcvt/filters.hxx #438560:438561
@@ -85,6 +85,57 @@
 };
 
 
+
+/** 
+* Glorified QString[N] for (a) understandability (b) older gcc compatibility. 
+*/
+template <unsigned int size> class FolderStructureBase
+{
+public:
+	typedef QString NString[size];
+	/** Constructor. Need a default constructor for QValueList. */
+	FolderStructureBase() {} ;
+
+	/** Constructor. Turn N QStrings into a folder structure 
+	*   description. 
+	*/
+	FolderStructureBase(const NString &s)
+	{
+	    for(unsigned int i=0; i<size; i++) d[i]=s[i];
+	} ;
+
+	/** Copy Constructor. */
+	FolderStructureBase(const FolderStructureBase &s)
+	{
+	    for(unsigned int i=0; i<size; i++) d[i]=s[i];
+	} ;
+
+	/** Assignment operator. Does the same thing as 
+	*   the copy constructor.
+	*/
+	FolderStructureBase &operator =(const FolderStructureBase &s)
+	{
+	    for(unsigned int i=0; i<size; i++) d[i]=s[i];
+	    return *this;
+	} ;
+
+	/** Access the different fields. There doesn't seem to
+	*   be a real semantics for the fields.
+	*/
+	const QString operator [](unsigned int i) const
+	{
+	    if (i<size) return d[i]; else return QString::null;
+	} ;
+
+	/** Access the different fields, for writing. */
+	QString &operator [](unsigned int i)
+	{
+	    Q_ASSERT(i<size);
+	    if (i<size) return d[i]; else return d[0];
+	} ;
+private:
+	QString d[size];
+} ;
+
 #endif
 
-// vim: ts=2 sw=2 et
Comment 10 Danny Kukawka 2005-07-25 13:11:29 UTC
please try to compile with this patch from branches/KDE/3.4/kdepim/kmailcvt/
Comment 11 Rex Dieter 2005-07-25 17:44:58 UTC
Verified patch to be mmm, mmm good.  Thanks.