gcc/analyzer/ChangeLog:
PR analyzer/101837
* analyzer.cc (maybe_reconstruct_from_def_stmt): Bail if fn is
NULL, and assert that it's non-NULL before passing it to
build_call_array_loc.
gcc/testsuite/ChangeLog:
PR analyzer/101837
* gcc.dg/analyzer/pr101837.c: New test.
tree return_type = gimple_call_return_type (call_stmt);
tree fn = fixup_tree_for_diagnostic_1 (gimple_call_fn (call_stmt),
visited);
+ if (fn == NULL_TREE)
+ return NULL_TREE;
unsigned num_args = gimple_call_num_args (call_stmt);
auto_vec<tree> args (num_args);
for (unsigned i = 0; i < num_args; i++)
return NULL_TREE;
args.quick_push (arg);
}
+ gcc_assert (fn);
return build_call_array_loc (gimple_location (call_stmt),
return_type, fn,
num_args, args.address ());
--- /dev/null
+/* { dg-additional-options "-O3 -fsanitize=undefined" } */
+
+void memory_exhausted();
+void memcheck(void *ptr) {
+ if (ptr) /* { dg-warning "leak" } */
+ memory_exhausted();
+}
+
+int emalloc(int size) { memcheck(__builtin_malloc(size)); } /* { dg-message "allocated here" } */
+int main() { int max_envvar_len = emalloc(max_envvar_len + 1); } /* { dg-message "use of uninitialized value 'max_envvar_len'" } */