* [PATCH] Fix pointer sharing in Value_Range constructor.
@ 2023-04-18 16:40 Aldy Hernandez
2023-04-19 12:25 ` Aldy Hernandez
0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2023-04-18 16:40 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
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
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix pointer sharing in Value_Range constructor.
2023-04-18 16:40 [PATCH] Fix pointer sharing in Value_Range constructor Aldy Hernandez
@ 2023-04-19 12:25 ` Aldy Hernandez
0 siblings, 0 replies; 2+ messages in thread
From: Aldy Hernandez @ 2023-04-19 12:25 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod
[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]
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.
[-- Attachment #2: 0001-Fix-pointer-sharing-in-Value_Range-constructor.patch --]
[-- Type: text/x-patch, Size: 798 bytes --]
From fc03caa0c94c9c11e0c1b1f7e7eba64233dbcfec Mon Sep 17 00:00:00 2001
From: Aldy Hernandez <aldyh@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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-19 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 16:40 [PATCH] Fix pointer sharing in Value_Range constructor Aldy Hernandez
2023-04-19 12:25 ` Aldy Hernandez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).