Skip to content

dbg.print_dead_code is not complete and reports statements inserted by CIL #94

@vogler

Description

@vogler

The behavior of the dead code reporting might confuse people.

#include <assert.h>

int main() {
  int x;
  if (1)
    x = 1;
  else
    x = 2;
  if (x)
    x = 1;
  else
    x = 2;
  assert(x > 1 && x < 0);
}
$ ./goblint --html dead.c
File 'dead.c':
  function 'main' has dead code on lines: 12, 14
Found dead code on 2 lines!
Dead code: the then branch over expression 'x > 1' is dead! (dead.c:13)
Dead code: the else branch over expression 'x' is dead! (dead.c:12)
Writing xml to temp. file: /var/folders/0j/1lq15k654zg7cf1rh9_gqty80000gn/T/ocaml61b1c3tmp
Time needed: 413 ms

image

It only reports dead code for nodes for which the solver calculated a value, but line 8 above is also dead (like all nodes that have no value).
On the other hand it reports about statements inserted by CIL, like the then-branch of the assert above.

Also, it might be useful to sort the output by line number.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions