This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/71852] New: add warning for conditions that can never be true


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]