bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] Re: warning: comparison is always false due to limited


From: Bruno Haible
Subject: Re: [bug-gnulib] Re: warning: comparison is always false due to limited range of data type
Date: Mon, 11 Jul 2005 13:22:18 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> Shouldn't we simply fix GCC instead?

I agree. The appended simpler test case (with 'unsigned short' instead of
'unsigned int', to see the warning on a 32-bit platform as well) produces
the warning with "gcc -Wall", even without -W, with any of 3.3.1, 3.4.3,
4.0.0.

It appears that gcc emits that message each time it can optimize the 'if'
away. When a compiler gives a warning on each optimization that it performs,
we can only ignore such warnings.

Bruno


=============================== foo.c =======================================
#include <stddef.h>
extern void foo ();
# define xalloc_oversized(n, s) \
    ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
void bar (unsigned short n)
{
  if (xalloc_oversized ((size_t)n, sizeof (int)))
    foo ();
}
=============================================================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]