<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 11, 2013, at 12:37 AM, Andrzej Krzemienski <<a href="mailto:akrzemi1@gmail.com">akrzemi1@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Everyone,<br>I wonder if it would be possible to have Clang Static Analyser check if function's preconditions are satisfied before the call. A precondition is an expression, and static analyser would have to check if the same (or similar) expression has been explicitly checked by the programmer or is guaranteed by other function's postcondition. </blockquote><div><br></div><div><br></div><div><div>Static analyzer would benefit form a programmer specifying pre- and postconditions in their code. Essentially, this is a way for the programmer to tell us more about their code, which makes it easier for us to find bugs. For example, we would check if a postcondition is violated after the function is executed and use the precondition to strengthen the set of assumptions on the function entry. Note that the analyzer will not be able to prove that the postcondition holds in general, we would just flag the cases where we can detect that it does not hold. (One could also insert runtime checks for these.)</div><div><br></div><div>Have you looked at Spec# research project, which includes a static program verifier? (<a href="http://research.microsoft.com/en-us/projects/specsharp/">http://research.microsoft.com/en-us/projects/specsharp/</a>) </div><div><br></div><div>SAL annotations are also somewhat related and those have been productized.</div><div><br></div><div>Anna.</div></div><br><blockquote type="cite">An example of what I mean is provided in the following post from group <span><a href="https://groups.google.com/a/isocpp.org/forum/?fromgroups#%21forum/std-proposals">ISO C++ Standard - Future Proposals</a>:</span><br>
<a href="https://groups.google.com/a/isocpp.org/d/msg/std-proposals/hUeCh-QCj0Y/aqX9W4ngjq0J">https://groups.google.com/a/isocpp.org/d/msg/std-proposals/hUeCh-QCj0Y/aqX9W4ngjq0J</a><br><br>I am trying to determine if the addition of Contract Programming features to C++ is enough to enable such enhanced static analysis, or if it would be just a "dead" feature.<br></blockquote><blockquote type="cite"><br>Regards,<br>&rzej<br>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></body></html>