<html><head><meta http-equiv="Content-Type" content="text/html charset=gb2312"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">We have a heuristic that is used to suppress common false positives. Specifically, the function may never return ΅®0΅― when called from the given call site. It is not the case here, but the heuristic is coarse grained and would benefit from tuning.. <span style="font-family: Menlo; font-size: 11px;" class="">See </span><span style="font-family: Menlo; font-size: 11px; color: rgb(180, 38, 26);" class="">-suppress-null-return-paths.</span><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(180, 38, 26);" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">Anna.</div><div><blockquote type="cite" class=""><div class="">On Nov 3, 2015, at 10:16 PM, ΧήΤ½ via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hi!<br class=""><br class=""><br class="">The code sample as below:<br class=""><br class="">-------------main.cpp----------------<br class=""><br class=""><blockquote class="">int* func(int b)<br class="">{<br class="">    if (b > 0)<br class="">    {       <span class="Apple-converted-space"> </span><br class="">        return new int[3];<br class="">    }<br class="">    return 0;<br class="">}<br class=""><br class="">void np_1(int* p, int b)<br class="">{<br class="">    p = func(b);<br class="">    *p = 123;<br class="">    return;<br class="">}<br class=""><br class=""></blockquote>---------------------------------------<br class=""><br class="">The command I ran: "<b class="">clang -cc1 -analyze -analyzer-checker=core.NullDereference main.cpp</b>".<br class="">In my opinion,there should report a null pointer dereference error at code "*p = 123", since "func" would return 0 if b is not greater than zero.<br class="">Howerver, no error reported. I debugged clang and found that "CheckerContext::emitReport()" indeed has been invoked when derefencing pointer p.<span class="Apple-converted-space"> </span><br class=""><br class="">clang version:<br class="">clang version 3.8.0 (trunk 248698)<br class="">Target: x86_64-apple-darwin15.0.0<br class="">Thread model: posix<br class=""><br class="">Can somebody tell me where the problem is?<span class="Apple-converted-space"> </span><br class="">Thanks in advance, Quark<br class=""><br class=""></div><span style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">cfe-dev mailing list</span><br style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:cfe-dev@lists.llvm.org" style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">cfe-dev@lists.llvm.org</a><br style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" style="font-family: ΞΆΘνΡΕΊΪ; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></div></blockquote></div><br class=""></div></body></html>