public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/104270] New: -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init=
@ 2022-01-28 15:32 dmalcolm at gcc dot gnu.org
2022-01-28 22:53 ` [Bug analyzer/104270] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-01-28 15:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104270
Bug ID: 104270
Summary: -Wanalyzer-use-of-uninitialized-value is incorrectly
suppressed by -ftrivial-auto-var-init=
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
As of GCC 12, the analyzer ought to complain about uses of uninitialized memory
via
-Wanalyzer-use-of-uninitialized-value
but fails to do so for trivial cases of locals when -ftrivial-auto-var-init= is
used with "pattern" or "zero".
The docs for -ftrivial-auto-var-init say:
> GCC still considers an automatic variable that doesn't have an explicit
> initializer as uninitialized, @option{-Wuninitialized} will still report
> warning messages on such automatic variables.
which implies that -ftrivial-auto-var-init is intended for mitigation, and that
the analyzer ought to still warn on such cases.
At the gimple level we have e.g.:
i_1 = .DEFERRED_INIT (4, 1, &"i"[0]);
which the analyzer doesn't yet have any special knowledge about, and thus
treats the result as a normal value, suppressing the warning.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug analyzer/104270] -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init=
2022-01-28 15:32 [Bug analyzer/104270] New: -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init= dmalcolm at gcc dot gnu.org
@ 2022-01-28 22:53 ` pinskia at gcc dot gnu.org
2022-02-02 14:52 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-28 22:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104270
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-01-28
Keywords| |diagnostic
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. I suspect it should be easy to treat DEFERRED_INIT as similar to ssa
names that are (D).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug analyzer/104270] -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init=
2022-01-28 15:32 [Bug analyzer/104270] New: -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init= dmalcolm at gcc dot gnu.org
2022-01-28 22:53 ` [Bug analyzer/104270] " pinskia at gcc dot gnu.org
@ 2022-02-02 14:52 ` cvs-commit at gcc dot gnu.org
2022-02-02 15:05 ` dmalcolm at gcc dot gnu.org
2022-02-02 21:51 ` cvs-commit at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-02 14:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104270
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
https://gcc.gnu.org/g:9b4eee5fd158c4ee75d1f1000debbf5082fb9b56
commit r12-6997-g9b4eee5fd158c4ee75d1f1000debbf5082fb9b56
Author: David Malcolm <dmalcolm@redhat.com>
Date: Fri Jan 28 11:02:09 2022 -0500
analyzer: stop -ftrivial-auto-var-init from suppressing uninit warnings
[PR104270]
GCC 12 has gained two features for dealing with uninitialized variables:
(a) a new -Wanalyzer-use-of-uninitialized-value warning within -fanalyzer
for interprocedural path-sensitive detection of ununit uses, and
(b) a new -ftrivial-auto-var-init option for mitigating some uses of
uninit variables
It turns out that using (b) was thwarting (a), as it led to -fanalyzer
seeing calls to IFN_DEFERRED_INIT, which -fanalyzer wasn't
special-casing, thus treating it as initializing the variables in
question, and thus silencing -Wanalyzer-use-of-uninitialized-value on
them.
invoke.texi says:
"GCC still considers an automatic variable that doesn't have an explicit
initializer as uninitialized, @option{-Wuninitialized} will still report
warning messages on such automatic variables."
and thus -Wanalyzer-use-of-uninitialized-value ought to as well.
This patch adds special-case handling to -fanalyzer for
IFN_DEFERRED_INIT, so that -fanalyzer will warn on uninit uses of
variables that are mitigated by -ftrivial-auto-var-init.
gcc/analyzer/ChangeLog:
PR analyzer/104270
* region-model.cc (region_model::on_call_pre): Handle
IFN_DEFERRED_INIT.
gcc/testsuite/ChangeLog:
PR analyzer/104270
* gcc.dg/analyzer/uninit-trivial-auto-var-init-pattern.c: New
test.
* gcc.dg/analyzer/uninit-trivial-auto-var-init-uninitialized.c:
New test.
* gcc.dg/analyzer/uninit-trivial-auto-var-init-zero.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug analyzer/104270] -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init=
2022-01-28 15:32 [Bug analyzer/104270] New: -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init= dmalcolm at gcc dot gnu.org
2022-01-28 22:53 ` [Bug analyzer/104270] " pinskia at gcc dot gnu.org
2022-02-02 14:52 ` cvs-commit at gcc dot gnu.org
@ 2022-02-02 15:05 ` dmalcolm at gcc dot gnu.org
2022-02-02 21:51 ` cvs-commit at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-02-02 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104270
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above commit.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug analyzer/104270] -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init=
2022-01-28 15:32 [Bug analyzer/104270] New: -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init= dmalcolm at gcc dot gnu.org
` (2 preceding siblings ...)
2022-02-02 15:05 ` dmalcolm at gcc dot gnu.org
@ 2022-02-02 21:51 ` cvs-commit at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-02 21:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104270
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:
https://gcc.gnu.org/g:fb45d8e692d41d0d5d0fea56791d5dca448009c5
commit r12-7007-gfb45d8e692d41d0d5d0fea56791d5dca448009c5
Author: David Malcolm <dmalcolm@redhat.com>
Date: Wed Feb 2 16:45:29 2022 -0500
docs: mention analyzer interaction with -ftrivial-auto-var-init [PR104270]
gcc/ChangeLog:
PR analyzer/104270
* doc/invoke.texi (-ftrivial-auto-var-init=): Add reference to
-Wanalyzer-use-of-uninitialized-value to paragraph documenting that
-ftrivial-auto-var-init= doesn't suppress warnings.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-02 21:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 15:32 [Bug analyzer/104270] New: -Wanalyzer-use-of-uninitialized-value is incorrectly suppressed by -ftrivial-auto-var-init= dmalcolm at gcc dot gnu.org
2022-01-28 22:53 ` [Bug analyzer/104270] " pinskia at gcc dot gnu.org
2022-02-02 14:52 ` cvs-commit at gcc dot gnu.org
2022-02-02 15:05 ` dmalcolm at gcc dot gnu.org
2022-02-02 21:51 ` cvs-commit 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).