lkml.org 
[lkml]   [2001]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [IDEA+RFC] Possible solution for min()/max() war
Roman Zippel wrote:
> > 3. Warning added to GCC for signed vs. unsigned comparisons
> > _regardless_ of type size. This would also catch erroneous
> > unsigned char vs. EOF checks in misuses of stdio.
>
> Do you know of such bug in the context of min()?

I don't know of an actual example. This one is made up:

min (int, len, big_size)

Now if big_size has unsigned type, and does not fit in the range of int,
this expression will return the value of big_size cast to int, i.e. a
negative value. The suggested warning would catch this potential bug.

I don't know if it would warn for too many other things. Certainly, a
sizeof() exception (don't warn about signed comparison with sizeof()
result) is essential; perhaps too many other exceptions are required
too.

-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:01    [from the cache]
©2003-2011 Jasper Spaans