aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2023-10-15 14:53:14 +0900
committerYusuke Endoh <mame@ruby-lang.org>2023-10-15 15:35:45 +0900
commit591336a0f278bf963d01b6e9810cfc86a5b50620 (patch)
treed34c234d6528953a8d0f3e9aa34b6ca1be5916c3 /internal
parent985b0244dae306c8e436da234a8bd4c8c322acf5 (diff)
downloadruby-591336a0f278bf963d01b6e9810cfc86a5b50620.tar.gz
Avoid the pointer hack in RCLASS_EXT
... because GCC 13 warns it. ``` In file included from class.c:24: In function ‘RCLASS_SET_ALLOCATOR’, inlined from ‘class_alloc’ at class.c:251:5, inlined from ‘rb_module_s_alloc’ at class.c:1045:17: internal/class.h:159:43: warning: array subscript 0 is outside array bounds of ‘rb_classext_t[0]’ {aka ‘struct rb_classext_struct[]’} [-Warray-bounds=] 159 | RCLASS_EXT(klass)->as.class.allocator = allocator; | ^ ``` https://rubyci.s3.amazonaws.com/arch/ruby-master/log/20231015T030003Z.log.html.gz
Diffstat (limited to 'internal')
-rw-r--r--internal/class.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/class.h b/internal/class.h
index 9bc1caf6a9..b055f07317 100644
--- a/internal/class.h
+++ b/internal/class.h
@@ -85,7 +85,12 @@ struct RClass {
// Assert that classes can be embedded in size_pools[2] (which has 160B slot size)
STATIC_ASSERT(sizeof_rb_classext_t, sizeof(struct RClass) + sizeof(rb_classext_t) <= 4 * RVALUE_SIZE);
-#define RCLASS_EXT(c) ((rb_classext_t *)((char *)(c) + sizeof(struct RClass)))
+struct RClass_and_rb_classext_t {
+ struct RClass rclass;
+ rb_classext_t classext;
+};
+
+#define RCLASS_EXT(c) (&((struct RClass_and_rb_classext_t*)(c))->classext)
#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
#define RCLASS_IVPTR(c) (RCLASS_EXT(c)->iv_ptr)