by ExpiredLink · 11y ago · 0 comments
Funny, because asserts in C are used to find bugs but not for "error handling and reporting".
If a speed sensitive function in C is documented to work for integers in the range 0 < x < 256, then it makes sense to put in an assert() as a courtesy to the users of the function.
It does not make sense in every situation to do a range check and return an error, or worse, "panic" (the latter didn't work for the Ariane 5).
Losing asserts doesn't eliminate either option. It simply requires you to have exicit error handling or a panic. This is the point.