<<< Date Index >>>     <<< Thread Index >>>

Re: Little code cleanup



On 2008-03-04 17:24:25 +1100, Cameron Simpson wrote:
> Couldn't they be moved into assertions? Would that shut up the compiler?

I doubt it.

> After all, the expressions are not "constant expressions" like the
> "if (1)" and "do...while(0)" conter examples; they're non-constant
> test expressions whose values can be deduced to never be false; it's
> reasonable for the compiler to point out this instance (provided one
> could tell it "yes, yes, I know!")

The fact they are constant expressions doesn't matter. For instance,
compiling

#include <limits.h>
int main (int argc, char **argv)
{
  return !(argc <= INT_MAX);
}

with gcc -Wall doesn't trigger any warning either, though one always
have argc <= INT_MAX. See also

  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963

where gcc used to issue a warning for a similar reason and no longer
does this in version 4.3.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)