diff mbox series

[5/5] ranger: Fix LTO uninitialized variable warning about m_range_tree

Message ID 20240806212714.308434-6-quic_apinski@quicinc.com
State New
Headers show
Series some small ranger op table cleanup | expand

Commit Message

Andrew Pinski Aug. 6, 2024, 9:27 p.m. UTC
With LTO, initialize_integral_ops, initialize_integral_ops and initialize_float_ops
are all inlined into the constructor of range_op_table, so you get an uninitialized
warning about m_range_tree not being initialized due to it having a clobber at the
begining of the constructor. This adds a value initialization for m_range_tree to have
it initialized inside the constructor. This has a small startup cost since we are zeroing
the whole array a second time though since we setting it later on to be, the cost of pulling
it into the cache is going to be small.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* range-op.h (class range_op_table): Value initialize m_range_tree.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
 gcc/range-op.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gcc/range-op.h b/gcc/range-op.h
index f7ecc660fb9..265d3c21691 100644
--- a/gcc/range-op.h
+++ b/gcc/range-op.h
@@ -404,7 +404,12 @@  private:
       gcc_checking_assert (m_range_tree[code] == NULL);
       m_range_tree[code] = &op;
     }
-  range_operator *m_range_tree[RANGE_OP_TABLE_SIZE];
+
+  /* m_range_tree needs to be value initialized instead
+     of default initialized; otherwise it could be considered
+     as unitialized even though it is zero initialized due to
+     being a static variable, there is a clobber in the ctor. */
+  range_operator *m_range_tree[RANGE_OP_TABLE_SIZE]{};
   void initialize_integral_ops ();
   void initialize_pointer_ops ();
   void initialize_float_ops ();