<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And there will be no injection of undefined behaviour - the undefined<br>
behaviour is already there if the asserted constraints are not valid.<br>
</blockquote>
<br></div>
Well, no. <a href="http://en.wikipedia.org/wiki/Undefined_behavior" target="_blank">http://en.wikipedia.org/wiki/<u></u>Undefined_behavior</a><br>
</blockquote></div><br></div><div class="gmail_extra">Well, yes: Undefined behaviour in the sense the writer of the program has not defined it.</div><div class="gmail_extra"><br></div><div class="gmail_extra">A program is written with certain assumptions about the state at certain points.  An assert can be used to explicitly state those assumptions, and halt the program (in non-release) if the assumptions are invalid.  If the state does not match what the assert assumes it to be, then any code relying on that state is invalid, and what it does has no definition given by the programmer.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">(And here I've circled back to assert==assume... all because I assume what assert means)</div><div class="gmail_extra"><br></div><div class="gmail_extra">If the state that is being checked could actually ever be valid, then it is not valid for an assert - use some other validation.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>