lkml.org 
[lkml]   [1997]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Style question: comparison between signed and unsigned?

On Wed, 24 Sep 1997, Mike Jagdis wrote:

> On Tue, 23 Sep 1997, Theodore Y. Ts'o wrote:
>
> > The fact of the matter is, by having the compiler issue these warnings,
> > it makes folks much more likely to ignore *all* compiler warnings, since
> > so many of them will be false positives.
>
> In my experience it means that programmers start to figure C is
> so dumb they have to explicitly cast *everything* - which not
> only makes it impossible to read their code but ensures neither
> the compiler nor the human has the faintest idea whether the
> programmer *really* intended a type conversion or if there is
> a bug lurking. Not good.

Um, how is this worse then having tons of implicit and undocumented
typecasts hidden throughout the code?

Dumb programmers write dumb programs. Granted. Smart programmers take
advantage of this behavior, and only typecast when this warning comes up
and they have looked at the situation and decided yes, the conversion is
what they mean (or changed the types of other variables to the correct
type). Speaking as someone who has ported a device driver from 32 to 64
bits, this warning can be a life saver (this particular warning caught
several cases where a function wasn't prototyped, so instead of returning
an unsigned long it was being treated as returning an int, causing an
signed->unsigned conversion warning (and also causing the 32-bit value to
go from 0x80200000 (right) to 0xFFFFFFFF80200000 (wrong)). A similiar
warning caught when I was writing a 64-bit value to a 32-bit register
(problems...).

For those who still don't beleive, I think GCC provides a way to turn
those warnings off on the command line (-Wno-something).

>
> Mike

Brian
I don't speak for Bit 3.


\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.743 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site