Messages in this thread |  | | Date | Fri, 31 Aug 2001 17:27:54 +0100 | | From | Jamie Lokier <> | | Subject | Re: [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/
|  |