Re: Style question: comparison between signed and unsigned?

Theodore Y. Ts'o (tytso@MIT.EDU)
Tue, 23 Sep 1997 16:56:46 -0400


From: Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>
Date: 23 Sep 1997 22:50:54 +0200

> Even with a package that's completely under my control, I don't want to
> have to remember that a particular warning is meaningless --- how often
> do *you* remember that line 415's signed/unsigned mismatch is harmless,
> but line 750's signed/unsigned mismatch represents a real bug?

I don't need to remember. I look at the sources, change the type of
the involved variables/expressions or add a cast. The point is that
*I* decided what is correct and don't rely on the compiler making the
decision for me. Once I fixed this I never again see the line 415
warning.

OK, so your argument *is* to throw around casts with abandon. This
causes another problem --- folks who add casts simply to shut up GCC.

Linus's argument was that a programming style which encourages huge
numbers of casts merely to shut up the warning mechanism is a bad idea.
Here I will stand with Linus.

>From your argumentation I haven't read that you are against having
this option around for newly developed code. You seem to care for old
code. But than this is only argument of somebody who wants to avoid
work. If you are not willing to spend this time go on and disable
this warning. Maybe you can re-enable it once you cleaned your
sources. But -Wall should definitely contain these warnings since so
newly developed code is written correctly right from the start.

I had a proposal (which means a more work for the gcc developers) which
would avoid the false positives without requiring huge numbers of casts.
I will note that no one has yet to respond to it, instead perferring to
wag their fingers about bad programming style....

- Ted