aboutsummaryrefslogtreecommitdiffstats
path: root/vm_callinfo.h
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-10-13 19:23:46 +0900
committerAaron Patterson <aaron.patterson@gmail.com>2022-10-13 08:14:04 -0700
commit2cc3963a00868ef6ff84a8b3bccca778592b3c2d (patch)
treebd92ed3502bdbf4b188f90e75c661e8f5b84bd91 /vm_callinfo.h
parent4b1504ae0a5118153f8b47d7bd0fff7e61553d17 (diff)
downloadruby-2cc3963a00868ef6ff84a8b3bccca778592b3c2d.tar.gz
Prevent wrong integer expansion
`(attr_index + 1)` leads to wrong integer expansion on 32-bit machines (including Solaris 10 CI) because `attr_index_t` is uint16_t. http://rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20221013T080004Z.fail.html.gz ``` 1) Failure: TestRDocClassModule#test_marshal_load_version_2 [/export/home/users/chkbuild/cb-gcc/tmp/build/20221013T080004Z/ruby/test/rdoc/test_rdoc_class_module.rb:493]: <[doc: [doc (file.rb): [para: "this is a comment"]]]> expected but was <[doc: [doc (file.rb): [para: "this is a comment"]]]>. 2) Failure: TestRDocStats#test_report_method_line [/export/home/users/chkbuild/cb-gcc/tmp/build/20221013T080004Z/ruby/test/rdoc/test_rdoc_stats.rb:460]: Expected /\#\ in\ file\ file\.rb:4/ to match "The following items are not documented:\n" + "\n" + " class C # is documented\n" + "\n" + " # in file file.rb\n" + " def m1; end\n" + "\n" + " end\n" + "\n" + "\n". 3) Failure: TestRDocStats#test_report_attr_line [/export/home/users/chkbuild/cb-gcc/tmp/build/20221013T080004Z/ruby/test/rdoc/test_rdoc_stats.rb:91]: Expected /\#\ in\ file\ file\.rb:3/ to match "The following items are not documented:\n" + "\n" + " class C # is documented\n" + "\n" + " attr_accessor :a # in file file.rb\n" + "\n" + " end\n" + "\n" + "\n". ```
Diffstat (limited to 'vm_callinfo.h')
-rw-r--r--vm_callinfo.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/vm_callinfo.h b/vm_callinfo.h
index e59f25ca59..2002718881 100644
--- a/vm_callinfo.h
+++ b/vm_callinfo.h
@@ -457,13 +457,13 @@ vm_cc_attr_index_set(const struct rb_callcache *cc, attr_index_t index, shape_id
}
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
VM_ASSERT(cc != vm_cc_empty());
- *attr_value = (index + 1) | ((uintptr_t)(dest_shape_id) << SHAPE_FLAG_SHIFT);
+ *attr_value = (attr_index_t)(index + 1) | ((uintptr_t)(dest_shape_id) << SHAPE_FLAG_SHIFT);
}
static inline void
vm_ic_attr_index_set(const rb_iseq_t *iseq, const struct iseq_inline_iv_cache_entry *ic, attr_index_t index, shape_id_t dest_shape_id)
{
- *(uintptr_t *)&ic->value = ((uintptr_t)dest_shape_id << SHAPE_FLAG_SHIFT) | (index + 1);
+ *(uintptr_t *)&ic->value = ((uintptr_t)dest_shape_id << SHAPE_FLAG_SHIFT) | (attr_index_t)(index + 1);
}
static inline void