This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/56153] New: False warning about signed and unsigned type in conditional expression
- From: "d.daniel at propharma dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 30 Jan 2013 15:44:43 +0000
- Subject: [Bug c/56153] New: False warning about signed and unsigned type in conditional expression
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56153
Bug #: 56153
Summary: False warning about signed and unsigned type in
conditional expression
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: d.daniel@propharma.ch
The following code creates a warning "signed and unsigned type in conditional
expression" but there is no such comparison:
typedef struct {
unsigned int num;
const char *str;
} FooBar;
FooBar *foo = (FooBar *)malloc (sizeof (FooBar));
foo->num = 0;
foo->str = "Hello World";
fprintf (stdout, "%d", foo != 0 ? foo->num : -1);
If instead, the following code gets compiled, no warning is issued:
// .. the same as above
fprintf (stdout, "%d", foo != 0 ? foo->num : 1);