Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following example fails to tests for conditions where a is neither b nor c. This may be the correct behavior in this case, but failure to account for all the values of a may result in logic errors if a unexpectedly assumes a different value.

...

The following compliant solution explicitly checks for the unexpected condition and handles it appropriatleyappropriately.

Code Block
...
if (a == b) {
  ...
}
else if (a == c) {
  ...
}
else {
  assert( (a==b) || (a == c) );
  abort();
}
...

...

The following example fails to tests for conditions where a is neither b nor cconsider all possible cases. This may be the correct behavior in this case, but failure to account for all the values of a may result in logic errors if a unexpectedly assumes a different value.

...

The following compliant solution explicitly checks for the unexpected condition and handles it appropriatleyappropriately.

Code Block
...
switch(a) {
  case: 1
    break;
  ...
  default:
     assert( (a==b) || (a == c) );
     abort();
}
...

...

Hatton 95 Section 2.7.2 Errors of ommision omission and addition