gcc4 warnings -Wuninitialized -Wfloat-equal and -Wconversion
Thiago Macieira
thiago at kde.org
Fri Aug 28 16:29:27 BST 2009
Em Sexta-feira 28 Agosto 2009, às 15:24:56, você escreveu:
> Hi,
>
> There are warnings in gcc4.4 (also in gcc 4.3), -Wuninitialized
> -Wfloat-equal and -Wconversion, that warn about common problems, that are
> not included in -Wall.
From -Wuninitialized:
This warning is enabled by `-Wall' or `-Wextra'.
The other two aren't included in -Wall or -Wextra.
> Do you think this warning should be included by default in the kde debug
> compilation options?
It already is:
$ grep -- -Wall cmake/modules/FindKDE4Internal.cmake
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -
std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -
Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -
Wmissing-format-attribute -fno-common")
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-
long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -
Wformat-security -fno-exceptions -fno-check-new -fno-common")
> -Wfloat-equal shows also some warnings. Those are easily avoided as Qt
> provides a way to compare floating points up to a small epsilon.
>
> For example:
> kdelibs/kdecore/config/kcoreconfigskeleton.cpp:665: warning: comparing
> floating point with == or != is unsafe
> kdelibs/kdecore/config/kcoreconfigskeleton.h:274: warning: comparing
> floating point with == or != is unsafe
> kdelibs/kdecore/config/kcoreconfigskeleton.h:277: warning: comparing
> floating point with == or != is unsafe
>
> Again, Do you think this warning should be included by default in the kde
> debug compilation options?
This one makes sense to enable. Though, of course, they'll be there forever,
since in some cases the exact comparison was intended.
> -Wconversion shows a lot more warnings (>5000 in kdelibs), for example:
>
> kdelibs/kdecore/sycoca/ksycocadict.cpp: In constructor
> ‘KSycocaDict::KSycocaDict(QDataStream*, int)’:
> kdelibs/kdecore/sycoca/ksycocadict.cpp:104: warning: conversion to
> ‘qint32’ from ‘qint64’ may alter its value
> kdelibs/kdecore/sycoca/ksycocadict.cpp: In member function ‘void
> KSycocaDict::save(QDataStream&)’:
> kdelibs/kdecore/sycoca/ksycocadict.cpp:337: warning: conversion to
> ‘qint32’ from ‘qint64’ may alter its value
> kdelibs/kdecore/sycoca/ksycocadict.cpp:457: warning: conversion to
> ‘qint32’ from ‘qint64’ may alter its value
> kdelibs/kdecore/sycoca/ksycocadict.cpp:487: warning: conversion to ‘int’
> from ‘qint64’ may alter its value kdelibs/kdecore/sycoca/ksycocadict.cpp:
> In member function ‘qint32 KSycocaDict::Private::offsetForKey(const
> QString&) const’: kdelibs/kdecore/sycoca/ksycocadict.cpp:542: warning:
> conversion to ‘uint’ from ‘long unsigned int’ may alter its value
>
> Again, Do you think this warning should be included by default in the kde
> debug compilation options?
Please don't.
First of all, we have already far too many warnings showing up, some of which
are important to be seen. Flooding the output with 5000 more warnings will
just make the important ones drown.
Most of the cases are false-positives anyway, so let's not enable more
warnings until we fix the ones we already have.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090828/752a060c/attachment.sig>
More information about the kde-core-devel
mailing list