This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Need someone to look at a regression
- To: Carlo Wood <carlo at runaway dot xs4all dot nl>
- Subject: Re: Need someone to look at a regression
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Fri, 14 Aug 1998 22:29:41 -0600
- cc: egcs at cygnus dot com (egcs at cygnus dot com)
- Reply-To: law at cygnus dot com
In message <199808141440.QAA29307@jolan.ppro>you write:
> Hmm, I used to get a warning for this, because the
> test is always true (unsigned int is always >= 0):
>
> -------------------
> #include <stdio.h>
>
> int main(int argc, char **argv)
> {
> unsigned int j = argc;
>
> if (j >= 0)
> printf("%u > 0\n", j);
> else
> printf("%u < 0\n", j);
>
> return 0;
> }
Add "-W" and you'll get the desired warning.
> No warnings? I am not sure if that is a bug or a feature, but
> since it is known that (unsigned int) != -1, it just seemed weird
> that the optimisation chooses to make j == -1 without a warning.
It is valid to compare an unsigned value against -1.
jeff