public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level
@ 2021-07-22 7:36 shen980630 at gmail dot com
2021-07-22 10:32 ` [Bug tree-optimization/101573] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: shen980630 at gmail dot com @ 2021-07-22 7:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101573
Bug ID: 101573
Summary: uninitialized warning could not appear correclty in
-O0 optimisation level
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: shen980630 at gmail dot com
Target Milestone: ---
Hi there,
with the code example below, -O0 -Wunitialized could not display the
uninitialized warning correctly while -O1 -Wunitialized could.
==============
int main() {
int a;
for(; a < 5; ++a)
;
return 0;
}
==============
> gcc-12 -O0 -Wuninitialized test.c
produces no warning
> gcc-12 -O1 -Wuninitialized test.c
produces:
test.c: In function 'main':
test.c:3:13: warning: 'a' is used uninitialized [-Wuninitialized]
3 | for(; a < 5; ++a)
|
For comparison, clang with -O0 could correctly display this warning.
> clang -O0 -Wuninitialized test.c
produces:
test.c:3:11: warning: variable 'a' is uninitialized when used here
[-Wuninitialized]
for(; a < 5; ++a)
^
test.c:2:10: note: initialize the variable 'a' to silence this warning
int a;
^
= 0
1 warning generated.
This behaviour happens in all the versions from gcc-7 to gcc-12 and the latest
version we checked is gcc (GCC) 12.0.0 20210520 (experimental), it also happens
with higher optimisation levels, -O2, -O3, -Os.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101573] uninitialized warning could not appear correclty in -O0 optimisation level
2021-07-22 7:36 [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level shen980630 at gmail dot com
@ 2021-07-22 10:32 ` rguenth at gcc dot gnu.org
2021-07-22 10:35 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-22 10:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101573
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
Component|c |tree-optimization
Blocks| |24639
Keywords| |diagnostic
Ever confirmed|0 |1
Severity|normal |enhancement
Last reconfirmed| |2021-07-22
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-O0 doesn't run the flow-sensitive uninit part, so that's expected. What we
could improve is walk PHIs and look at fallthru edges PHI uses.
I have a patch doing that.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101573] uninitialized warning could not appear correclty in -O0 optimisation level
2021-07-22 7:36 [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level shen980630 at gmail dot com
2021-07-22 10:32 ` [Bug tree-optimization/101573] " rguenth at gcc dot gnu.org
@ 2021-07-22 10:35 ` rguenth at gcc dot gnu.org
2021-07-27 8:46 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-22 10:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101573
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 51195
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51195&action=edit
patch
patch in testing
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101573] uninitialized warning could not appear correclty in -O0 optimisation level
2021-07-22 7:36 [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level shen980630 at gmail dot com
2021-07-22 10:32 ` [Bug tree-optimization/101573] " rguenth at gcc dot gnu.org
2021-07-22 10:35 ` rguenth at gcc dot gnu.org
@ 2021-07-27 8:46 ` cvs-commit at gcc dot gnu.org
2021-07-27 8:47 ` rguenth at gcc dot gnu.org
2022-08-29 13:25 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-27 8:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101573
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:66030d68a7edfc9504a50469598e0707b8f787ce
commit r12-2525-g66030d68a7edfc9504a50469598e0707b8f787ce
Author: Richard Biener <rguenther@suse.de>
Date: Thu Jul 22 12:26:16 2021 +0200
tree-optimization/101573 - improve uninit warning at -O0
We can improve uninit warnings from the early pass by looking
at PHI arguments on fallthru edges that are uninitialized and
have uses that are before a possible loop exit. This catches
some cases earlier that we'd only warn in a more confusing
way after early inlining as seen by testcase adjustments.
It introduces
FAIL: gcc.dg/uninit-23.c (test for excess errors)
where we additionally warn
gcc.dg/uninit-23.c:21:13: warning: 't4' is used uninitialized
[-Wuninitialized]
which I think is OK even if it's not obvious that the new
warning is an improvement when you look at the obvious source.
Somehow for all cases I never get the `'foo' was declared here`
notes, I didn't dig why that happens but it's odd.
2021-07-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/101573
* tree-ssa-uninit.c (warn_uninit_phi_uses): New function
looking at uninitialized PHI arg defs in some constrained cases.
(warn_uninitialized_vars): Call it.
(execute_early_warn_uninitialized): Calculate dominators.
* gcc.dg/uninit-pr101573.c: New testcase.
* gcc.dg/uninit-15-O0.c: Adjust.
* gcc.dg/uninit-15.c: Likewise.
* gcc.dg/uninit-23.c: Likewise.
* c-c++-common/uninit-17.c: Likewise.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101573] uninitialized warning could not appear correclty in -O0 optimisation level
2021-07-22 7:36 [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level shen980630 at gmail dot com
` (2 preceding siblings ...)
2021-07-27 8:46 ` cvs-commit at gcc dot gnu.org
@ 2021-07-27 8:47 ` rguenth at gcc dot gnu.org
2022-08-29 13:25 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-27 8:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101573
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |12.0
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 12.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/101573] uninitialized warning could not appear correclty in -O0 optimisation level
2021-07-22 7:36 [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level shen980630 at gmail dot com
` (3 preceding siblings ...)
2021-07-27 8:47 ` rguenth at gcc dot gnu.org
@ 2022-08-29 13:25 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-29 13:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101573
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |phresnel at gmail dot com
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
*** Bug 43361 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-29 13:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 7:36 [Bug c/101573] New: uninitialized warning could not appear correclty in -O0 optimisation level shen980630 at gmail dot com
2021-07-22 10:32 ` [Bug tree-optimization/101573] " rguenth at gcc dot gnu.org
2021-07-22 10:35 ` rguenth at gcc dot gnu.org
2021-07-27 8:46 ` cvs-commit at gcc dot gnu.org
2021-07-27 8:47 ` rguenth at gcc dot gnu.org
2022-08-29 13:25 ` rguenth 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).