-
Notifications
You must be signed in to change notification settings - Fork 629
Closed
Description
The following code does not raise the SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW
although the while loop does not use the result
variable (making it a dead store) and the switch
falls through to throw
.
class DeadStoreBug {
public int showBug(int input) {
int i = 0;
int result = 0;
switch (input) {
case 1:
result = 10;
while (i < input) {
System.out.println(i);
i++;
}
case 2:
throw new RuntimeException("Invalid input");
default:
result = input * 2;
}
return result;
}
}
SpotBugs version: 4.9.2
Java: Temurin openjdk 21.0.7
Ran from CLI as the following two commands:
export SPOTBUGS_JAR=/path/to/spotbugs.jar
javac DeadStoreBug.java && \
java -jar $SPOTBUGS_JAR \
-low \
-effort:max \
DeadStoreBug.class
Expectation: raises SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH_TO_THROW
.
Metadata
Metadata
Assignees
Labels
No labels