The GNU compiler extension that allows case
s to be specified with ranges should only be used when a range is actually needed. Use it
with the same number on both ends of the range, and you’ve either made a mistake because an actual range was intended, or you’ve used the syntax
inappropriately in a way that is highly likely to confuse maintainers.
Noncompliant code example
switch (i) {
case 0:
//...
break;
case 1 ... 2:
//...
break;
case 3 ... 3: // Noncompliant
//...
break;
}
Compliant solution
switch (i) {
case 0:
//...
break;
case 1 ... 2:
//...
break;
case 3:
//...
break;
}
or
switch (i) {
case 0:
//...
break;
case 1 ... 2:
//...
break;
case 3 ... 5:
//...
break;
}