-Wunused-but-set-variable warnings
Michael Pyne
mpyne at kde.org
Mon Jul 4 18:31:09 BST 2011
On Monday, July 04, 2011 12:02:47 Dawit A wrote:
> The following files all contain set but unused variables:
>
> kdelibs/kdecore/util/kshareddatacache.cpp:751:14: warning: variable
> ‘freedPagesRequired’ set but not used [-Wunused-but-set-variable]
Thanks for the heads-up on this one!
> Unlike the -Wunused-parameter fixing this warning messages requires
> context because the variable may be set and unused due to a mistake
> that can potentially be causing a bug.
In this case it was not, but as you point out that was only due to other
things going on afterwards.
> As such can kdelibs cmake file
> be changed to error out, -Werror=unused-but-set-variable, for such
> warnings ?
I really kind of abhor -Werror in all of its incarnations. It's like holding a
whole village hostage until one man gives themselves up to the posse. In this
case it would affect /anyone/ trying to simply build KDE (even if they have
more advanced compilers with more warnings generated than the developer who
would need to make the fix).
Being unable even to build kdelibs, kde-workspace, etc. would make it very
difficult for other developers to properly build and *test* the code that they
are working on elsewhere. So while we should certainly apply social pressure
to compile without warnings and ensure bug-free code, don't overdo it! The
likely thing to come from such a decision is that the warnings are "fixed" by
hastily-applied patches that either do not fix the problem, or possibly even
introduce new ones.
I almost broke KSharedDataCache in a way I wouldn't have been able to easily
test until I took a bit more time to think about what the code was actually
doing now, and needed to be doing.
Regards,
- Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20110704/906897a0/attachment.sig>
More information about the kde-core-devel
mailing list