Package: gcc-4.6
Version: 4.6-20110216-1
Severity: wishlist
Tags: upstream

Hi,

$ gcc -c -std=gnu99 -Wtype-limits -x c - <<-\EOF
enum test_enum {
        FOO,
        BAR
};

int valid(enum test_enum arg)
{
        return arg >= FOO && arg <= BAR;
}
EOF
<stdin>: In function ‘valid’:
<stdin>:8:9: warning: comparison of unsigned expression >= 0 is always true 
[-Wtype-limits]
$ 

Since C99 (WG14/N1256 p105, lang.decl.typespec.enum.4) only says:

        Each enumerated type shall be compatible with char, a signed
        integer type, or an unsigned integer type. The choice of type
        is implementation-defined) but shall be capable of
        representing the values of all the members of the enumeration.

the (arg >= FOO) test is not actually redundant.

Thoughts?
Jonathan



--
To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20110227065213.GA23734@elie

Reply via email to