This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/59293] New: Bogus -Wsign-compare warning when using typeof() on a constant
- From: "shawn at churchofgit dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 Nov 2013 19:59:01 +0000
- Subject: [Bug c/59293] New: Bogus -Wsign-compare warning when using typeof() on a constant
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59293
Bug ID: 59293
Summary: Bogus -Wsign-compare warning when using typeof() on a
constant
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: shawn at churchofgit dot com
#define MAX(a,b) \
__extension__ ({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a > _b ? _a : _b; \
})
int main() {
if (MAX(5, (unsigned)3))
return 1;
return 0;
}
gives:
excessive_signed_compare.c:5:28: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
_a > _b ? _a : _b; \
^
excessive_signed_compare.c:9:6: note: in expansion of macro âMAXâ
if (MAX(5, (unsigned)3))
^
excessive_signed_compare.c:5:38: warning: signed and unsigned type in
conditional expression [-Wsign-compare]
_a > _b ? _a : _b; \