<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">Yes, you are completely correct. I ALWAYS put semicolons after</div>
asserts, to make them look like any other function call.<br></blockquote><div><br></div><div>Indeed, even for the correct definition of non-debug assert ((void)0) you would need a semicolon after it to ensure the next function call was correctly parsed. (eg, this: "((void)0) func();" should fail to compile).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">But I am COMPLETELY CERTAIN that putting an assert() inside of an if<br>
statement without also placing it in a Basic Block totally broke my<br>
VC++ code. The program I was integrating my library with was a<br>
financial package that produced graphs. If I graphed the output from<br>
both my library and the client's old library, with my assert inside<br>
the if, those two graphs subtly diverged. When I fixed my code to use<br>
a Basic Block instead, the two graphs coincided perfectly.<br></blockquote><div><br></div><div>It'd be really interesting to see the repro so we could see what we're actually dealing with/trying to address. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I still have the Visual Studio 7.0 installer. I'm not sure but I<br>
think 7.1 is an update one can download from Microsoft's site. I<br>
could install them both then just have a look at <assert.h> to see how<br>
it is defined.<br></blockquote><div><br></div><div>I'd love to see what was going on.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Even if all modern compilers do the right thing, I assert (!) it would<br>
still be useful to write the analysis, as it would catch portability<br>
problems. There are lots of coders who still use broken old<br>
compilers. I still hear about people using Visual Studio 6!<br></blockquote><div><br></div><div>Certainly they are, though it might be a lesser priority for clang to try to address such broken standard libraries.</div><div>
<br></div><div>As for the general problem of non-debug builds possibly changing control flow that could be an interesting puzzle (& even in the presence of well behaved standard libraries it could still be a problem:</div>
<div><br></div><div>if (foo)<br>#ifndef NDEBUG<br> printDebugInfo();<br>#endif<br>doImportantProductionWork();<br><br>) for the static analyzer to possibly play with, but I do wonder if it might produce a lot of false positives on code that might be legitimately trying to change behavior under debug builds in some way or another. Might require a fair few heuristics to reduce that noise - though that's not necessarily a reason not to try it out & see what it looks like.</div>
<div><br></div><div>- David</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
Ever Faithful,<br>
<br>
Don Quixote<br>
--<br>
</div><div class="im">Don Quixote de la Mancha<br>
</div><div><div></div><div class="h5">Dulcinea Technologies Corporation<br>
Software of Elegance and Beauty<br>
<a href="http://www.dulcineatech.com" target="_blank">http://www.dulcineatech.com</a><br>
<a href="mailto:quixote@dulcineatech.com">quixote@dulcineatech.com</a><br>
</div></div></blockquote></div><br>