Comment by samiv
5 hours ago
That's why you define your own assert macro and keep in on unconditionally. Your programs will be better for it.
5 hours ago
That's why you define your own assert macro and keep in on unconditionally. Your programs will be better for it.
An assertion can be arbitrarily expensive to evaluate. This may be worth the cost in a debug build but not in a release build. If all of assertions are cheap, they likely are not checking nearly as much as they could or should.
Possibly but I've never seen it in practice that some assert evaluation would be the first thing to optimize. Anyway should that happen then consider removing just that assert.
That being said being slow or fast is kinda moot point if the program is not correct. So my advisor to leave always all asserts in. Offensive programming.