On Sunday, 3 August 2014 at 21:57:08 UTC, John Carter wrote:
On Sunday, 3 August 2014 at 19:47:27 UTC, David Bregman wrote:
Walter has proposed a change to D's assert function as follows
[1]:
"The compiler can make use of assert expressions to improve
optimization, even in -release mode."
Hmm. I really really do like that idea.
I suspect it is one of those ideas of Walter's that has
consequences that reach further than anyone foresees..... but
that's OK, because it is fundamentally the correct course of
action, it's implications foreseen and unforeseen will be
correct.
One "near term" implication is to permit deeper static checking
of the code.
I allow myself to chime in. I don't have much time to follow the
whole thing, but I have this in my mind for quite a while.
First thing first, the proposed behavior is what I had in mind
for SDC since pretty much day 1. It already uses hint for the
optimizer to tell it the branch won't be taken, but I
definitively want to go further.
By definition, when an assert has been removed in release that
would have failed in debug, you are in undefined behavior land
already. So there is no reason not to optimize.