This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/71852] New: add warning for conditions that can never be true
- From: "tromey at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 12 Jul 2016 19:44:36 +0000
- Subject: [Bug c/71852] New: add warning for conditions that can never be true
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71852
Bug ID: 71852
Summary: add warning for conditions that can never be true
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: tromey at gcc dot gnu.org
Target Milestone: ---
Consider this code, derived from some code in gdb's arm-tdep.c:
int main(int argc, char**argv)
{
unsigned int aa = argc;
aa = aa & 0x04;
if (aa == 0x00) {
// Ok.
} else if (aa == 0x01) {
// Ok.
} else if (aa == 0x0b) {
// Oops.
}
}
Here, two of the conditions can never be true.
I think it would be nice if gcc could warn for this case.