arminbiere / cadical

CaDiCaL SAT Solver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`uip` is always true

sfiruch opened this issue · comments

PVS Studio (https://pvs-studio.com/en/order/for-students/#IDD159822EC6) found this potential problem.

The if statement on analyze.cpp:1186 is superfluous. uip must be non-zero because of the while loop on line 1093:

  uip = 0;
  while (!uip) {
    assert (i > 0);
    const int lit = (*t)[--i];
    if (!flags (lit).seen)
      continue;
    if (var (lit).level == level)
      uip = lit;
  }

https://github.com/arminbiere/cadical/blob/e7369b4b04fafe8b4b139d5e181528f5006d0816/src/analyze.cpp#L1186C4-L1186C4

Looks like redundant indeed but not harmful.

It is probably better to keep it as it is, since this function is pretty complex and somewhat defensive code is better in these cases.