public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/94774] New: Uninitialized variable retval in function try_substitute_return_value
@ 2020-04-26 15:05 stefansf at linux dot ibm.com
2020-04-27 15:34 ` [Bug tree-optimization/94774] " msebor at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: stefansf at linux dot ibm.com @ 2020-04-26 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94774
Bug ID: 94774
Summary: Uninitialized variable retval in function
try_substitute_return_value
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: stefansf at linux dot ibm.com
Target Milestone: ---
Created attachment 48377
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48377&action=edit
If SAFE then retval was initialised
While bootstrapping GCC on S/390 the following warning/error gets thrown:
gcc/gimple-ssa-sprintf.c: In function 'bool
handle_printf_call(gimple_stmt_iterator*, const vr_values*)':
gcc/gimple-ssa-sprintf.c:4184:8: error: '*((void*)& retval +8)' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
4183 | && (retval[0] < target_int_max ()
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4184 | && retval[1] < target_int_max ()))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc/gimple-ssa-sprintf.c:4123:26: note: '*((void*)& retval +8)' was declared
here
4123 | unsigned HOST_WIDE_INT retval[2];
| ^~~~~~
gcc/gimple-ssa-sprintf.c:4214:14: error: 'retval' may be used uninitialized in
this function [-Werror=maybe-uninitialized]
4214 | fprintf (dump_file, " %s %s-bounds return value "
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4215 | HOST_WIDE_INT_PRINT_UNSIGNED ".\n",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4216 | what, inbounds, retval[0]);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc/gimple-ssa-sprintf.c:4123:26: note: 'retval' was declared here
4123 | unsigned HOST_WIDE_INT retval[2];
| ^~~~~~
The attached patch fixes this for me. Otherwise, one could also just initialize
array retval which may be more appropriate?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94774] Uninitialized variable retval in function try_substitute_return_value
2020-04-26 15:05 [Bug middle-end/94774] New: Uninitialized variable retval in function try_substitute_return_value stefansf at linux dot ibm.com
@ 2020-04-27 15:34 ` msebor at gcc dot gnu.org
2020-04-27 16:51 ` stefansf at linux dot ibm.com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-04-27 15:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94774
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
It looks to me like only the second warning might be a true positive. The
first one seems spurious since the uninitialized access is guarded by the test
for safe being true.
Moving the guard up would suppress the dump output in the "unsafe" case so I
don't think that's what we want. OTOH, ether initializing the array, or
unconditionally assigning to it in is_call_safe, seems benign.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94774] Uninitialized variable retval in function try_substitute_return_value
2020-04-26 15:05 [Bug middle-end/94774] New: Uninitialized variable retval in function try_substitute_return_value stefansf at linux dot ibm.com
2020-04-27 15:34 ` [Bug tree-optimization/94774] " msebor at gcc dot gnu.org
@ 2020-04-27 16:51 ` stefansf at linux dot ibm.com
2020-04-29 13:54 ` cvs-commit at gcc dot gnu.org
2020-09-03 18:48 ` manu at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: stefansf at linux dot ibm.com @ 2020-04-27 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94774
--- Comment #2 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> ---
(In reply to Martin Sebor from comment #1)
> Moving the guard up would suppress the dump output in the "unsafe" case so I
> don't think that's what we want. OTOH, ether initializing the array, or
> unconditionally assigning to it in is_call_safe, seems benign.
Since is_call_safe is called with a dummy argument in try_simplify_call I went
for initialising the array. I will come up with a patch and post it to the
mailinglist. Thanks for your help!
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94774] Uninitialized variable retval in function try_substitute_return_value
2020-04-26 15:05 [Bug middle-end/94774] New: Uninitialized variable retval in function try_substitute_return_value stefansf at linux dot ibm.com
2020-04-27 15:34 ` [Bug tree-optimization/94774] " msebor at gcc dot gnu.org
2020-04-27 16:51 ` stefansf at linux dot ibm.com
@ 2020-04-29 13:54 ` cvs-commit at gcc dot gnu.org
2020-09-03 18:48 ` manu at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-29 13:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94774
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Stefan Schulze Frielinghaus
<stefansf@gcc.gnu.org>:
https://gcc.gnu.org/g:1657178f59bf0c5b269a668bcdcc432fac3bbdd0
commit r10-8050-g1657178f59bf0c5b269a668bcdcc432fac3bbdd0
Author: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Date: Mon Apr 27 18:09:07 2020 +0200
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 <stefansf@linux.ibm.com>
PR tree-optimization/94774
* gimple-ssa-sprintf.c (try_substitute_return_value): Initialize
variable retval.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/94774] Uninitialized variable retval in function try_substitute_return_value
2020-04-26 15:05 [Bug middle-end/94774] New: Uninitialized variable retval in function try_substitute_return_value stefansf at linux dot ibm.com
` (2 preceding siblings ...)
2020-04-29 13:54 ` cvs-commit at gcc dot gnu.org
@ 2020-09-03 18:48 ` manu at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2020-09-03 18:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94774
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
CC| |manu at gcc dot gnu.org
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Seems fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-03 18:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 15:05 [Bug middle-end/94774] New: Uninitialized variable retval in function try_substitute_return_value stefansf at linux dot ibm.com
2020-04-27 15:34 ` [Bug tree-optimization/94774] " msebor at gcc dot gnu.org
2020-04-27 16:51 ` stefansf at linux dot ibm.com
2020-04-29 13:54 ` cvs-commit at gcc dot gnu.org
2020-09-03 18:48 ` manu at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).