On 4/18/23 18:40, Aldy Hernandez wrote:
I will push this when a final round of testing finishes on x86-64 Linux. gcc/ChangeLog: * value-range.h (Value_Range::Value_Range): Avoid pointer sharing. --- gcc/value-range.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index 0eeea79b322..f97596cdd14 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -583,7 +583,18 @@ Value_Range::Value_Range (tree min, tree max, value_range_kind kind) inline Value_Range::Value_Range (const Value_Range &r) { - m_vrange = r.m_vrange; + if (r.m_vrange == &r.m_irange) + { + m_irange = r.m_irange; + m_vrange = &m_irange; + } + else if (r.m_vrange == &r.m_frange) + { + m_frange = r.m_frange; + m_vrange = &m_frange; + } + else + m_vrange = &m_unsupported; }// Initialize object so it is possible to store temporaries of TYPE
Upon further thought I realized operator= will do all the right things, and makes the code easier to read.
Re-tested and pushed.
From fc03caa0c94c9c11e0c1b1f7e7eba64233dbcfec Mon Sep 17 00:00:00 2001 From: Aldy Hernandez <al...@redhat.com> Date: Mon, 6 Mar 2023 13:53:15 +0100 Subject: [PATCH] Fix pointer sharing in Value_Range constructor. gcc/ChangeLog: * value-range.h (Value_Range::Value_Range): Avoid pointer sharing. --- gcc/value-range.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index 0eeea79b322..33ef3b5b8d8 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -583,7 +583,7 @@ Value_Range::Value_Range (tree min, tree max, value_range_kind kind) inline Value_Range::Value_Range (const Value_Range &r) { - m_vrange = r.m_vrange; + *this = *r.m_vrange; } // Initialize object so it is possible to store temporaries of TYPE -- 2.40.0