This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51712] New: -Wtype-limits should not trigger for types of implementation-defined signedness
- From: "jrnieder at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Dec 2011 07:02:09 +0000
- Subject: [Bug c/51712] New: -Wtype-limits should not trigger for types of implementation-defined signedness
- Auto-submitted: auto-generated
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