* [PATCH] avoid using uninitialized offset (PR 92622)
@ 2019-12-05 22:22 Martin Sebor
2019-12-05 22:35 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Martin Sebor @ 2019-12-05 22:22 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 375 bytes --]
I've isolated the intermittent failures of a test for a recent
enhancement to -Warray-bounds reported in PR 92622 to the use
of an offset left uninitialized by a failed call to
get_addr_base_and_unit_offset.
The attached patch makes sure the variable is only used if
the call succeeds. I will commit it tomorrow unless there
are objections/suggestions for changes.
Martin
[-- Attachment #2: gcc-92622.diff --]
[-- Type: text/x-patch, Size: 1869 bytes --]
PR middle-end/92622 - FAIL: gcc.dg/Warray-bounds-22.c on ILP32: missing warnings for VLA on lines 67 and 69
gcc/ChangeLog:
PR testsuite/92622
* tree-vrp.c (vrp_prop::check_array_ref): Avoid using a variable
left uninitialized by get_addr_base_and_unit_offset ofn failure.
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 279008)
+++ gcc/tree-vrp.c (working copy)
@@ -3516,7 +3516,6 @@ vrp_prop::check_array_ref (location_t location, tr
tree ptrdiff_max = TYPE_MAX_VALUE (ptrdiff_type_node);
tree maxbound = ptrdiff_max;
tree arg = TREE_OPERAND (ref, 0);
- poly_int64 off;
const bool compref = TREE_CODE (arg) == COMPONENT_REF;
if (compref)
@@ -3535,19 +3534,22 @@ vrp_prop::check_array_ref (location_t location, tr
size wouldn't necessarily be correct if the reference is
to its flexible array member initialized in a different
translation unit. */
- tree base = get_addr_base_and_unit_offset (arg, &off);
- if (!compref && base && DECL_P (base))
- if (tree basesize = DECL_SIZE_UNIT (base))
- if (TREE_CODE (basesize) == INTEGER_CST)
- {
- maxbound = basesize;
- decl = base;
- }
+ poly_int64 off;
+ if (tree base = get_addr_base_and_unit_offset (arg, &off))
+ {
+ if (!compref && DECL_P (base))
+ if (tree basesize = DECL_SIZE_UNIT (base))
+ if (TREE_CODE (basesize) == INTEGER_CST)
+ {
+ maxbound = basesize;
+ decl = base;
+ }
- if (known_gt (off, 0))
- maxbound = wide_int_to_tree (sizetype,
- wi::sub (wi::to_wide (maxbound),
- off));
+ if (known_gt (off, 0))
+ maxbound = wide_int_to_tree (sizetype,
+ wi::sub (wi::to_wide (maxbound),
+ off));
+ }
}
else
maxbound = fold_convert (sizetype, maxbound);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] avoid using uninitialized offset (PR 92622)
2019-12-05 22:22 [PATCH] avoid using uninitialized offset (PR 92622) Martin Sebor
@ 2019-12-05 22:35 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2019-12-05 22:35 UTC (permalink / raw)
To: Martin Sebor, gcc-patches
On Thu, 2019-12-05 at 15:22 -0700, Martin Sebor wrote:
> PR middle-end/92622 - FAIL: gcc.dg/Warray-bounds-22.c on ILP32:
> missing warnings for VLA on lines 67 and 69
>
> gcc/ChangeLog:
>
> PR testsuite/92622
> * tree-vrp.c (vrp_prop::check_array_ref): Avoid using a
> variable
> left uninitialized by get_addr_base_and_unit_offset ofn
> failure.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-05 22:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 22:22 [PATCH] avoid using uninitialized offset (PR 92622) Martin Sebor
2019-12-05 22:35 ` 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).