Message ID | 20200427165827.4014766-1-stefansf@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | [PR94774] tree-optimization: Fix use of uninitialized variable | expand |
On 4/27/20 10:58 AM, Stefan Schulze Frielinghaus wrote: > Array retval is not necessarily initialized by function is_call_safe and > may be used afterwards. Thus, initialize it explicitly. > > Ok for master? The change looks (even obviously) good to me but strictly speaking it needs the approval of a middle end maintainer. Thanks Martin > > gcc/ChangeLog: > > 2020-04-27 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> > > PR tree-optimization/94774 > * gimple-ssa-sprintf.c (try_substitute_return_value): Initialize > variable retval. > --- > gcc/gimple-ssa-sprintf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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 >
On Tue, Apr 28, 2020 at 6:14 PM Martin Sebor via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On 4/27/20 10:58 AM, Stefan Schulze Frielinghaus wrote: > > Array retval is not necessarily initialized by function is_call_safe and > > may be used afterwards. Thus, initialize it explicitly. > > > > Ok for master? > > The change looks (even obviously) good to me but strictly speaking > it needs the approval of a middle end maintainer. OK. Richard. > Thanks > Martin > > > > > gcc/ChangeLog: > > > > 2020-04-27 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> > > > > PR tree-optimization/94774 > > * gimple-ssa-sprintf.c (try_substitute_return_value): Initialize > > variable retval. > > --- > > gcc/gimple-ssa-sprintf.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > 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 > > >
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