On Monday, 28 July 2014 at 19:16:24 UTC, Ola Fosheim Grøstad wrote:
Why should the situation be different if I use the builtin `assert` instead?

No difference. Except with a builtin you can get additional debugger support, so that you don't have to recompile when following a complicated trace that trigger asserts.

Well, actually, that is not correct. There are other advantages too.

If the compiler guarantees that asserts don't have side effects (on optimization) and aren't affected by the optimizer then you are more likely to see the same behaviour in debug and release builds even with heavy optimization turned on (such as various math approximations). E.g. you can verify with exact math in the assert() that the fast-math approximations the optimizer makes on running code are within the acceptable tolerance level.

Reply via email to