public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51712] New: -Wtype-limits should not trigger for types of implementation-defined signedness
@ 2011-12-30  9:19 jrnieder at gmail dot com
  2012-03-26 10:45 ` [Bug c/51712] " manu at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: jrnieder at gmail dot com @ 2011-12-30  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51712
           Summary: -Wtype-limits should not trigger for types of
                    implementation-defined signedness
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jrnieder@gmail.com
                CC: manu@gcc.gnu.org


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. It would be nice to
automatically suppress the warning in this case.

What do you think? Feasible?

Originally reported as http://bugs.debian.org/615525


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-10-29 13:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-30  9:19 [Bug c/51712] New: -Wtype-limits should not trigger for types of implementation-defined signedness jrnieder at gmail dot com
2012-03-26 10:45 ` [Bug c/51712] " manu at gcc dot gnu.org
2012-03-26 20:19 ` jrnieder at gmail dot com
2012-04-17 17:52 ` manu at gcc dot gnu.org
2012-04-17 18:19 ` jrnieder at gmail dot com
2012-04-17 22:10 ` manu at gcc dot gnu.org
2012-04-23 21:12 ` joseph at codesourcery dot com
2012-04-26 12:00 ` manu at gcc dot gnu.org
2012-05-03 22:38 ` manu at gcc dot gnu.org
2012-05-03 23:13 ` manu at gcc dot gnu.org
2012-10-16  7:56 ` jrnieder at gmail dot com
2012-10-16  8:43 ` manu at gcc dot gnu.org
2012-10-29 13:25 ` manu at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).