V577. Label is present inside a switch(). It is possible that these are misprints and 'default:' operator should be used instead.


The analyzer detected a potential error inside the switch operator. A label is used whose name is similar to 'default'. A misprint is probable. Consider this sample:

int c = 10;
int r = 0;
switch(c){
case 1:
  r = 3; break;
case 2:
  r = 7; break;
defalt:
  r = 8; break;
}

It seems that after the code's work is done, the value of the 'r' variable will be 8. Actually the 'r' variable will still equal zero. The point is that "defalt" is a label, not the "default" operator. This is the correct code:

int c = 10;
int r = 0;
switch(c){
case 1:
  r = 3; break;
case 2:
  r = 7; break;
default:
  r = 8; break;
}

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-478.


Bugs Found

Checked Projects
344
Collected Errors
12 970