Tai-e-assignments
Tai-e-assignments copied to clipboard
Confusion about A3 testcase Loops.java
The check mechanism in testcase method deadLoop() inside "Loops.java" is inproper. I must add cfg.exitNode(), which is nop, to the visited nodes at first to get passed. However, according to my observation, the predecessor of the nop is return which indicates the nop is actually dead code.
Additionally, I also wonder should I assume the cfg.exitNode() can eventually be visited. Without this assumption, I can still discover all reachable nodes by performing BFS from the entry node. Am I overlooking some corner cases?
Here is the source code of testcase "Loops.java":
class Loops {
void deadLoop() {
int x = 1;
int y = 0;
int z = 100;
while (x > y) {
use(z);
}
dead(); // unreachable branch
}
void dead() {
}
void use(int n) {
}
}