1 Sep 2005 01:09
Re: warning: comparison is always false due to limited range of data type
Paul Eggert <eggert <at> CS.UCLA.EDU>
2005-08-31 23:09:31 GMT
2005-08-31 23:09:31 GMT
Jim Meyering <jim <at> meyering.net> writes: > Is it really permitted to have sizeof (size_t) < sizeof (unsigned int)? Yes, I'm afraid so. The C Standard merely says that size_t is an unsigned integer type; size_t is allowed to be narrower than unsigned int. See, for example, Mark Brader's 10-year-old post on this subject in <http://groups.google.com/group/comp.std.c/msg/70cbd32ec8543738> (originally <news:1996Jun6.203847.26420 <at> sq.com>). > Sounds pretty darn perverted, and I'll bet it would make lots of code break. I agree. I can't imagine it occuring on a general-purpose host. Maybe some of the odder embedded hosts. It's not worth worrying about if it takes real work to make the code portable. >> Also, I'd rather not penalize all compilers just because GCC is busted. > > I understand the point, but wonder if this `penalty' > is even measurable, in practice. Not here; but I am a bit worried about the precedent. Checking for size-arithmetic overflow can slow things down quite a bit in some other cases. (Perhaps I'm being overly influenced here by the regex code, which I've been looking at for a bit, and which I'm afraid contains many arithmetic-overflow bugs....) > The offending warning breaks coreutils' `make distcheck' rule. Would it make sense to rewrite coreutils 'make distcheck' to filter(Continue reading)
RSS Feed