<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; "><div>Ah, apparently assert() <a href="http://msdn.microsoft.com/en-us/library/vstudio/9sb57dw4.aspx">isn't automatically fatal</a> in the CRT:</div><div><br></div><blockquote type="cite"><div><p style="color: rgb(102, 102, 102); margin-top: 0px; margin-bottom: 14px; padding-bottom: 15px; line-height: 21px; font-size: 14px; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; background-color: rgb(255, 255, 255); position: static; z-index: auto; ">When the application is linked with a debug version of the run-time libraries, <strong>assert</strong> creates a message box with three buttons: <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Abort</span>, <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Retry</span>, and <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Ignore</span>. If the user clicks <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Abort</span>, the program aborts immediately. If the user clicks <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Retry</span>, the debugger is called and the user can debug the program if just-in-time (JIT) debugging is enabled. If the user clicks <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Ignore</span>, <strong>assert</strong> continues with its normal execution: creating the message box with the <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">OK</span> button. Note that clicking <span class="label" style="font-weight: bold; font-family: 'Segoe UI Bold', 'Segoe UI', Helvetica, Garuda, Arial, sans-serif;">Ignore</span> when an error condition exists can result in undefined behavior.</p></div></blockquote><div>If this was a user-owned library, we'd ask them to add __attribute__((analyzer_noreturn)), but as is adding _wassert to NoReturnFunctionChecker seems like the best thing to do.</div><div><br></div><div>Jordan</div><div><br></div><br><div><div>On Nov 11, 2013, at 8:25 , Anders Montonen <<a href="mailto:Anders.Montonen@iki.fi">Anders.Montonen@iki.fi</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">FWIW I tried adding _wassert to NoReturnFunctionChecker, and it appeared to do the trick.<br><br>-a<br><br>On Mon, 11 Nov 2013, David Blaikie wrote:<br><br><blockquote type="cite">+Jordan - do you know much about the NoReturnFunctionChecker and whether it<br>would make sense to handle _wassert there? Is there some other solution that<br>would properly handle this implementation of 'assert' in the static<br>analyzer?<br>On Mon, Nov 11, 2013 at 3:01 AM, Anders Montonen <<a href="mailto:Anders.Montonen@iki.fi">Anders.Montonen@iki.fi</a>><br>wrote:<br> Hi,<br><br> I'm trying to use Clang's static analyzer with a Visual Studio<br> project, but I'm running into the problem that in Microsoft's<br> headers the _wassert function is not declared as noreturn, which<br> leads to lots of false positives. The assert declaration looks<br> like so:<br><br> #undef assert<br><br> #define assert(_Expression) (void)( (!!(_Expression)) ||<br> (_wassert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__),<br> __LINE__), 0) )<br><br> _CRTIMP void __cdecl _wassert(_In_z_ const wchar_t * _Message,<br> _In_z_ const wchar_t *_File, _In_ unsigned _Line);<br><br> Looking through the source code there seems to be an "--assert="<br> flag, but it also seems not to be used.<br><br> Any advice how to handle this? Since the mingw headers (where<br> the function is properly annotated) differ enough from<br> Microsoft's that it would require modifications in the source<br> code, I would prefer to not have to include them in the mix.<br><br> I noticed that there's a number of hardcoded function names in<br> the static analyzer's NoReturnFunctionChecker, should _wassert<br> be added to this list?<br><br> -a<br><br> _______________________________________________<br> cfe-users mailing list<br> <a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a><br></blockquote></blockquote></div><br></body></html>