]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimple-ssa-warn-alloca: Always initialize limit [PR99989]
authorJakub Jelinek <jakub@redhat.com>
Sat, 10 Apr 2021 10:48:04 +0000 (12:48 +0200)
committerJakub Jelinek <jakub@redhat.com>
Sat, 10 Apr 2021 10:48:04 +0000 (12:48 +0200)
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  <jakub@redhat.com>

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

index e776aad14e44f668ebfd9883cf79a5496d06c990..42c0ba1d87b4567239364accf8b82712c8b52851 100644 (file)
@@ -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);
   }
 };