Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -286,7 +286,7 @@ } ArrayRef parameters = getCallParameters(Call); - for (unsigned I = 0, E = Call->getNumArgs(); I != E; ++I) { + for (unsigned I = 0; I < Call->getNumArgs() && I < parameters.size(); ++I) { const ParmVarDecl *PVD = parameters[I]; SVal S = Call->getArgSVal(I); unsigned IndirectionLevel = 1; Index: cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp =================================================================== --- cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp +++ cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp @@ -145,3 +145,18 @@ return s.x; // expected-warning{{Undefined or garbage value returned to caller}} // expected-note@-1{{Undefined or garbage value returned to caller}} } + +void *has_no_argument_and_returns_null(void) { + return 0; +} + +void rdar40335545() { + int local; // expected-note{{}} + void (*takes_int_ptr_argument)(int *) = (void (*)(int*))has_no_argument_and_returns_null; + + takes_int_ptr_argument(&local); // no-crash + + int useLocal = local; //expected-warning{{}} + //expected-note@-1{{}} + (void)useLocal; +}