[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warning: comparison is always false due to limited range of data typ
Re: warning: comparison is always false due to limited range of data type
Wed, 31 Aug 2005 16:09:31 -0700
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)
Jim Meyering <address@hidden> 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
> 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
out the bogus diagnostics? That might be a simpler fix.
> The cure, with all of those #if's, is looking worse than the disease.
You've convinced me. Let's ignore that #iffy patch and try to come up
with a better solution to the real problem.