From 3e350d8539a4e28ddc30d0f08a4040f10b699135 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 10 Apr 2021 12:48:04 +0200 Subject: [PATCH] gimple-ssa-warn-alloca: Always initialize limit [PR99989] This PR is about a -W*uninitialized warning on riscv64. alloca_type_and_limit is documented to have limit member only defined when type is ALLOCA_BOUND_MAYBE_LARGE or ALLOCA_BOUND_DEFINITELY_LARGE and otherwise just default constructs limit, which for wide_int means no initialization at all. IMHO it is fine not to use the limit member otherwise, but trying to not initialize it when it can be e.g. copied around and then invoke UB doesn't look like a good idea. 2021-04-10 Jakub Jelinek PR middle-end/99989 * gimple-ssa-warn-alloca.c (alloca_type_and_limit::alloca_type_and_limit): Initialize limit to 0 with integer precision unconditionally. --- gcc/gimple-ssa-warn-alloca.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c index e776aad14e44..42c0ba1d87b4 100644 --- a/gcc/gimple-ssa-warn-alloca.c +++ b/gcc/gimple-ssa-warn-alloca.c @@ -124,9 +124,8 @@ public: alloca_type_and_limit (enum alloca_type type, wide_int i) : type(type), limit(i) { } alloca_type_and_limit (enum alloca_type type) : type(type) - { if (type == ALLOCA_BOUND_MAYBE_LARGE - || type == ALLOCA_BOUND_DEFINITELY_LARGE) - limit = wi::to_wide (integer_zero_node); + { + limit = wi::to_wide (integer_zero_node); } }; -- 2.47.2