]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Mode-Switching: Fix local array maybe uninitialized warning
authorPan Li <pan2.li@intel.com>
Fri, 19 May 2023 23:49:00 +0000 (07:49 +0800)
committerPan Li <pan2.li@intel.com>
Sat, 20 May 2023 09:58:23 +0000 (17:58 +0800)
There are 2 local array in function optimize_mode_switching. It will be
initialized conditionally at the beginning but then always consumed in
another loop. It may trigger the warning maybe-uninitialized, and may
result in build failure when enable werror, aka warning as error.

This patch will initialize the local array to zero explictly when
declaration.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* mode-switching.cc (entity_map): Initialize the array to zero.
(bb_info): Ditto.

gcc/mode-switching.cc

index 2d2818f5674d561be02738712c339a9a2a4ad878..64ae2bc29c300735906420cdc5a26e68c95b6b34 100644 (file)
@@ -499,8 +499,8 @@ optimize_mode_switching (void)
   bool need_commit = false;
   static const int num_modes[] = NUM_MODES_FOR_MODE_SWITCHING;
 #define N_ENTITIES ARRAY_SIZE (num_modes)
-  int entity_map[N_ENTITIES];
-  struct bb_info *bb_info[N_ENTITIES];
+  int entity_map[N_ENTITIES] = {};
+  struct bb_info *bb_info[N_ENTITIES] = {};
   int i, j;
   int n_entities = 0;
   int max_num_modes = 0;