[Bug c/92286] New: Possible improvement for -Wduplicated-cond warning

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Oct 30 13:17:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92286

            Bug ID: 92286
           Summary: Possible improvement for -Wduplicated-cond warning
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

We can possibly improve the warning for:

cat main2.c
int global;
int foo();

int main2(int argc, char **argv)
{
  if (argc == 1)
    foo ();
  else if (argc == 2) {
    global += 1;
  }
  else if (argc == 3)
  {
    foo ();
    foo ();
  }
  else if (argc >= 1 && argc <= 2)
  {
    foo ();
  }

  global -= 12;
  return 0;
}

where (argc >= 1 && argc <= 2) condition is already covered.


More information about the Gcc-bugs mailing list