Using Assert For Error Handling
This may have been asked before but I was unable to find a definitive yes or no answer. I was reading an article today ( http://cacm.acm.org/magazines/2012/7/151224-my-compiler-does-not-understand-me/fulltext ) that argued assert is an underused function in programming languages. It argues instead of using complicated error checking on system calls that in the event they return a value signaling failure indicates a major underlying problem that will prevent the program from executing, we should instead use an assert statement that when failed causes the program to abort preventing potential damage caused by running code in the unstable environment. This conflicts with what I had been taught, which is that assert should be used exclusively for debugging and disabled in distributed code (as is referenced in the cplusplus tutorial: http://www.cplusplus.com/reference/clibrary/cassert/assert/ ). What are your thoughts here? Should assert be used as a tool for error handling in production code or should it be reserved exclusively for debugging?

This questions is specifically targeted towards C++ but can be extended to other languages as well.
Using Assert For Error Handling
===

This may have been asked before but I was unable to find a definitive yes or no answer. I was reading an article today ( http://cacm.acm.org/magazines/2012/7/151224-my-compiler-does-not-understand-me/fulltext ) that argued assert is an underused function in programming languages. It argues instead of using complicated error checking on system calls that in the event they return a value signaling failure indicates a major underlying problem that will prevent the program from executing, we should instead use an assert statement that when failed causes the program to abort preventing potential damage caused by running code in the unstable environment. This conflicts with what I had been taught, which is that assert should be used exclusively for debugging and disabled in distributed code (as is referenced in the cplusplus tutorial: http://www.cplusplus.com/reference/clibrary/cassert/assert/ ). What are your thoughts here? Should assert be used as a tool for error handling in production code or should it be reserved exclusively for debugging?

This questions is specifically targeted towards C++ but can be extended to other languages as well.