From 1657178f59bf0c5b269a668bcdcc432fac3bbdd0 Mon Sep 17 00:00:00 2001 From: Stefan Schulze Frielinghaus Date: Mon, 27 Apr 2020 18:09:07 +0200 Subject: [PATCH] tree-optimization: Fix use of uninitialized variable [PR94774] Array retval is not necessarily initialized by function is_call_safe and may be used afterwards. Thus, initialize it explicitly. gcc/ChangeLog: 2020-04-29 Stefan Schulze Frielinghaus PR tree-optimization/94774 * gimple-ssa-sprintf.c (try_substitute_return_value): Initialize variable retval. --- gcc/ChangeLog | 6 ++++++ gcc/gimple-ssa-sprintf.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a1100623dc9..f33193b0ec0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-04-29 Stefan Schulze Frielinghaus + + PR tree-optimization/94774 + * gimple-ssa-sprintf.c (try_substitute_return_value): Initialize + variable retval. + 2020-04-29 Richard Sandiford * calls.h (cxx17_empty_base_field_p): Turn into a function declaration. diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 1879686ce0a..011c3e21e63 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -4120,7 +4120,7 @@ try_substitute_return_value (gimple_stmt_iterator *gsi, bool removed = false; /* The minimum and maximum return value. */ - unsigned HOST_WIDE_INT retval[2]; + unsigned HOST_WIDE_INT retval[2] = {0}; bool safe = is_call_safe (info, res, true, retval); if (safe -- 2.30.2