Defensive programming: Difference between revisions

Content deleted Content added
JChMathae (talk | contribs)
Trusting internal data validity: Optimizing compilers are (too) smart
Line 63:
}
return "black"; // To be handled as a dead traffic light.
// WaringWarning: This last 'return' statement will be dropped by an optimizing
// compiler if all possible values of 'traffic_light_color' are listed in
// the previous 'switch' statement...
Line 78:
}
assert(0); // Assert that this section is unreachable.
// WaringWarning: This 'assert' function call will be dropped by an optimizing
// compiler if all possible values of 'traffic_light_color' are listed in
// the previous 'switch' statement...