On Saturday, 1 September 2018 at 20:15:15 UTC, Walter Bright
wrote:
https://blog.regehr.org/archives/1091
As usual, John nails it in a particularly well-written essay.
"ASSERT(expr)
Asserts that an expression is true. The expression may or may
not be evaluated.
If the expression is true, execution continues normally.
If the expression is false, what happens is undefined."
Note the "may or may not be evaluated." We've debated this here
before. I'm rather pleased that John agrees with me on this.
I.e. the optimizer can assume the expression is true and use
that information to generate better code, even if the assert
code generation is turned off.
I used to completely agree with your position about asserts being
used for optimization purposes, until I realized that part of
your position was for asserts to be used as optimization hints
*even if they aren't checked*.
This battle has been fought over and over, with no movement on
either side, so I'll just comment that nobody what John Nails or
anyone else says, my personal opinion is that you're 100% wrong
on that point :-)