https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> --- A pointer is known to non-null only if we know where the pointer is pointing to. Since the null field is initialized to 0, we need to check both null and anything. This works on the test case: diff --git a/gcc/value-query.cc b/gcc/value-query.cc index ab133aab114..1e8e3b96ea7 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -302,7 +302,7 @@ get_ssa_name_ptr_info_nonnull (const_tree name) When PTA analysis is improved, pt.anything, pt.nonlocal and pt.escaped may also has to be considered before deciding that pointer cannot point to NULL. */ - return !pi->pt.null; + return !pi->pt.null && !pi->pt.anything; } // Update the global range for NAME into the SSA_RANGE_NAME_INFO and