From f75561b8d455e1cf92dac8ac8838fdafc88cba71 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 22 Jul 2019 17:01:31 +0900 Subject: [PATCH] constify RHash::ifnone. RHash::ifnone should be protected by write-barriers so this field should be const. However, to introduce GC.compact, the const was removed. This commit revert this removing `const` and modify gc.c `TYPED_UPDATE_IF_MOVED` to remove `const` forcely by a type cast. --- gc.c | 2 +- internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 1c2959cbad..feea9852ec 100644 --- a/gc.c +++ b/gc.c @@ -915,7 +915,7 @@ static inline void gc_prof_set_heap_info(rb_objspace_t *); #define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \ if (gc_object_moved_p(_objspace, (VALUE)_thing)) { \ - (_thing) = (_type)RMOVED((_thing))->destination; \ + *((_type *)(&_thing)) = (_type)RMOVED((_thing))->destination; \ } \ } while (0) diff --git a/internal.h b/internal.h index b931c115df..f8baba48c1 100644 --- a/internal.h +++ b/internal.h @@ -873,7 +873,7 @@ struct RHash { struct ar_table_struct *ar; /* possibly 0 */ } as; int iter_lev; - VALUE ifnone; + const VALUE ifnone; }; #ifdef RHASH_ITER_LEV