From: Ivan Maidanski Date: Tue, 25 Oct 2016 21:56:02 +0000 (+0300) Subject: Eliminate 'dereference of null' CSA false warning in array_mark_proc X-Git-Tag: v7.6.2~391 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f842995de788fba6bf366a057393ce4c0e6550c3;p=gc Eliminate 'dereference of null' CSA false warning in array_mark_proc The exact warning message is: Access to field 'mse_start' results in a dereference of a null pointer (loaded from variable 'new_mark_stack_ptr'). Note: the warning is eliminated regardless of assertion checking status. * typd_mlc.c (GC_array_mark_proc): Call ABORT if mark_stack_ptr is NULL (thus orig_mark_stack_ptr is ensured to be non-NULL after the check). --- diff --git a/typd_mlc.c b/typd_mlc.c index b7688b06..3e063736 100644 --- a/typd_mlc.c +++ b/typd_mlc.c @@ -495,6 +495,9 @@ STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr, mark_stack_ptr, mark_stack_limit-1); if (new_mark_stack_ptr == 0) { + /* Explicitly instruct Clang Static Analyzer that ptr is non-null. */ + if (NULL == mark_stack_ptr) ABORT("Bad mark_stack_ptr"); + /* Doesn't fit. Conservatively push the whole array as a unit */ /* and request a mark stack expansion. */ /* This cannot cause a mark stack overflow, since it replaces */