Monday, June 13, 2016

Important semantic effects of small syntax errors : C++ conditional expression

Here's a typo that had dramatic effects:

if(processed_count =! container.size())
{
  . . .

Result: the code always thought that the whole container had been processed, even when it wasn't.

Had the codebase been running at maximum warnings, and treating warnings as errors, this would never have happened. Those compilation conditions are now active.

Always compile at maximum warnings and treat warnings as errors.

No comments:

Post a Comment