3 ms·
Consider this - you may not be able to hit your assumption with all possible inputs in debug/during development, or your function may accept user-provided input
by diath 3y ago
Consider this - you may not be able to hit your assumption with all possible inputs in debug/during development, or your function may accept user-provided input, you then release your software, and then somebody gets your code executed with a set of inputs that don't pass the assumption, now since it's an assert that's been effectively turned into a no-op in release, you're reading past the end of the buffer.
- arghwhat 3y agoasserts are not disabled in release builds unless you explicitly go out of your way to do so.
- josefx 3y agoVarious build tool chains disable them implicitly for release builds. You should probably assert #ifdef NDEBUG #error #endif In your source code if your code assumes that assertions will never be disabled.