[Top][All Lists]
[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
From: |
Jim Meyering |
Subject: |
Re: warning: comparison is always false due to limited range of data type |
Date: |
Wed, 22 Jun 2005 15:17:19 +0200 |
Paul Eggert <address@hidden> wrote:
>> "Oskar Liljeblad" <address@hidden> wrote:
...
>>> quotearg.c: In function `quotearg_n_options':
>>> quotearg.c:586: warning: comparison is always false due to limited range of
>>> data type
...
> My own experience is that that particular warning is more trouble
> than it's worth. Is there some easy way to ask GCC to not generate
> that warning?
GCC has no option to suppress that warning.
It's not pretty, but maybe as a last resort...
The following work-around suppresses the warning when
compiling with -Dlint.
Add this,
#ifdef lint
typedef size_t unsigned_int;
#else
typedef unsigned int unsigned_int;
#endif
and then change this:
unsigned int n1 = n0 + 1;
to this:
unsigned_int n1 = n0 + 1;
On 64-bit systems, that'd give warning-free builds with -Dlint,
at the expense of a small inefficiency. Without -Dlint, you'd
still get the tighter generated code, along with the warning.
On 32-bit systems, it should make no difference.
But then due diligence would seem to require
a comment justifying this apparent micro-optimization.
If using `size_t' unconditionally means you don't have to make
excuses in the comments, then perhaps it's better after all.
The difference in text size (using gcc-4.0 -O3) is just 16 bytes.
Besides, who knows... compilers may eventually be able to optimize
away that xalloc_die call, in spite of the intermediate size_t.
- warning: comparison is always false due to limited range of data type, Oskar Liljeblad, 2005/06/20
- Re: warning: comparison is always false due to limited range of data type, Jim Meyering, 2005/06/21
- Re: warning: comparison is always false due to limited range of data type, Paul Eggert, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type, Jim Meyering, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type, Oskar Liljeblad, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type, Jim Meyering, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type, Oskar Liljeblad, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type, Jim Meyering, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type,
Jim Meyering <=
- Re: warning: comparison is always false due to limited range of data type, Paul Eggert, 2005/06/22
- Re: warning: comparison is always false due to limited range of data type, Jim Meyering, 2005/06/23