Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Validate assert() calls to be removable. #232
In almost all software the usage of 'assert()' statements are purely for the programmer, a way to make sure assumptions that the programmer makes while coding are correct during operations.
It is a very good rule to make sure that such statements can be removed from code without affecting the actual execution of the code.
because if you remove the assert, the code will stop working in the second case because the call to crucial operation is also removed.
In Bitcoin, unlike most software, the asserts are NOT removed in production code and when I recently found the above example in code, I got worried that there may be more calls like this in the code.
I think the only place these are still left are in the unit tests.
I personally think its perfectly Ok for a unit test to first show a BOOST_CHECK fail and then follow with a crash if the code references a null pointer or similar. To the test-runner this is practically the same as what an assert does anyway.