egcs-2.91.40 and Qt (was:Re: latest snapshot doesn't compile)

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Fri Jun 12 11:59:00 GMT 1998


Am Fri, 12 Jun 1998 schrieb Arnt Gulbrandsen:
>Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
>> egcs-2.91.40 19980612
>
>Hm.  I build Qt using gcc version egcs-2.90.29 980515 (egcs-1.0.3
>release) with no warnings...
>
>What does this program do?
>
>--- cut here ---
>
>#include <qstring.h>
>
>int main( int argc, char ** argv ) {
>    QString a( "stuff" );
>    const char * b = a;
>    printf( "->%s<-\n", b );
>}
>
>--- cut here ---
>
>That gives the warning, not?  What if you remove the operator const
>char * from qstring.h?  Does the program give warnings?  Does it work?
>
>I just can't see where egcs gets that other operator const char *
>from, and why it considers that other one to be worth consideration.
>I mean, the object is of type QString and QString itself provides an
>operator const char *: Why should the compiler even start looking for
>any other ways to cast?
>
>--Arnt

Yes, you are right, this small example gives a lot of the same errors, but
works correctly. I've cc'ed egcs-bugs and appended the .ii file of the
testcase, cause I really don't know a lot about c++.

Franz.

/usr/lib/qt/include/qstring.h: In function `class QString operator +(const class QString &, const class QString &)':
In file included from qstring.cc:2:
/usr/lib/qt/include/qstring.h:339: warning: choosing `QString::operator const char *() const' over `QArrayT<char>::operator const char *<char>() const'
/usr/lib/qt/include/qstring.h:339: warning:   for conversion from `const QString' to `const char *'
/usr/lib/qt/include/qstring.h:339: warning:   because conversion sequence for the argument is better
/usr/lib/qt/include/qstring.h: In function `class QString operator +(const char *, const class QString &)':
/usr/lib/qt/include/qstring.h:353: warning: choosing `QString::operator const char *() const' over `QArrayT<char>::operator const char *<char>() const'
/usr/lib/qt/include/qstring.h:353: warning:   for conversion from `const QString' to `const char *'
/usr/lib/qt/include/qstring.h:353: warning:   because conversion sequence for the argument is better
/usr/lib/qt/include/qstring.h: In function `class QString operator +(char, const class QString &)':
/usr/lib/qt/include/qstring.h:367: warning: choosing `QString::operator const char *() const' over `QArrayT<char>::operator const char *<char>() const'
/usr/lib/qt/include/qstring.h:367: warning:   for conversion from `const QString' to `const char *'
/usr/lib/qt/include/qstring.h:367: warning:   because conversion sequence for the argument is better
qstring.cc: In function `int main(int, char **)':
qstring.cc:7: warning: choosing `QString::operator const char *() const' over `QArrayT<char>::operator const char *<char>() const'
qstring.cc:7: warning:   for conversion from `QString' to `const char *'
qstring.cc:7: warning:   because conversion sequence for the argument is better
qstring.cc:8: warning: implicit declaration of function `int printf(...)'




More information about the Gcc-bugs mailing list