* [PATCH] Fix PRs 79955 and 79956 (hopefully)
@ 2017-03-08 10:12 Richard Biener
2017-03-08 10:18 ` Jakub Jelinek
2017-03-08 16:00 ` Jeff Law
0 siblings, 2 replies; 3+ messages in thread
From: Richard Biener @ 2017-03-08 10:12 UTC (permalink / raw)
To: gcc-patches
The following avoids warning about completely out-of-bound accesses
as uninitialized.
For GCC8 we likely want to enhance path isolation to catch those
cases (and eventually issue a diagnostic about them). And we
finally want to fix complete peeling to not introduce those
accesses.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2017-03-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/79955
PR tree-optimization/79956
* tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn
for accesses that are completely outside of the variable.
* gcc.dg/uninit-24.c: New testcase.
Index: gcc/tree-ssa-uninit.c
===================================================================
--- gcc/tree-ssa-uninit.c (revision 245968)
+++ gcc/tree-ssa-uninit.c (working copy)
@@ -287,6 +287,17 @@ warn_uninitialized_vars (bool warn_possi
|| TREE_NO_WARNING (base))
continue;
+ /* Do not warn if the access is fully outside of the
+ variable. */
+ if (ref.size != -1
+ && ref.max_size == ref.size
+ && (ref.offset + ref.size <= 0
+ || (ref.offset >= 0
+ && TREE_CODE (DECL_SIZE (base)) == INTEGER_CST
+ && compare_tree_int (DECL_SIZE (base),
+ ref.offset) <= 0)))
+ continue;
+
/* Limit the walking to a constant number of stmts after
we overcommit quadratic behavior for small functions
and O(n) behavior. */
Index: gcc/testsuite/gcc.dg/uninit-24.c
===================================================================
--- gcc/testsuite/gcc.dg/uninit-24.c (nonexistent)
+++ gcc/testsuite/gcc.dg/uninit-24.c (working copy)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wmaybe-uninitialized" } */
+
+int foo (int x)
+{
+ int y;
+ if (x)
+ return *(&y + 1); /* { dg-bogus "may be used uninitialized" } */
+ return 0;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix PRs 79955 and 79956 (hopefully)
2017-03-08 10:12 [PATCH] Fix PRs 79955 and 79956 (hopefully) Richard Biener
@ 2017-03-08 10:18 ` Jakub Jelinek
2017-03-08 16:00 ` Jeff Law
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2017-03-08 10:18 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Wed, Mar 08, 2017 at 11:12:47AM +0100, Richard Biener wrote:
>
> The following avoids warning about completely out-of-bound accesses
> as uninitialized.
>
> For GCC8 we likely want to enhance path isolation to catch those
> cases (and eventually issue a diagnostic about them). And we
> finally want to fix complete peeling to not introduce those
> accesses.
>
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
LGTM, thanks.
> 2017-03-08 Richard Biener <rguenther@suse.de>
>
> PR tree-optimization/79955
> PR tree-optimization/79956
> * tree-ssa-uninit.c (warn_uninitialized_vars): Do not warn
> for accesses that are completely outside of the variable.
>
> * gcc.dg/uninit-24.c: New testcase.
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix PRs 79955 and 79956 (hopefully)
2017-03-08 10:12 [PATCH] Fix PRs 79955 and 79956 (hopefully) Richard Biener
2017-03-08 10:18 ` Jakub Jelinek
@ 2017-03-08 16:00 ` Jeff Law
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2017-03-08 16:00 UTC (permalink / raw)
To: Richard Biener, gcc-patches
On 03/08/2017 03:12 AM, Richard Biener wrote:
>
> The following avoids warning about completely out-of-bound accesses
> as uninitialized.
>
> For GCC8 we likely want to enhance path isolation to catch those
> cases (and eventually issue a diagnostic about them). And we
> finally want to fix complete peeling to not introduce those
> accesses.
FWIW, I want to do isolation of o-o-b array accesses and this would
likely fit into that reasonably well.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-08 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 10:12 [PATCH] Fix PRs 79955 and 79956 (hopefully) Richard Biener
2017-03-08 10:18 ` Jakub Jelinek
2017-03-08 16:00 ` Jeff Law
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).