summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2026-05-26 14:50:45 -0700
committerGitHub <noreply@github.com>2026-05-26 14:50:45 -0700
commitdcfba5725794815fa36e129457f9d748f24371f9 (patch)
tree5d0c3f0eebef7e34775e56ebf27bc2890c675740 /internal
parentce7f3ed832a50e493e3b6cb592791aa1fe784d85 (diff)
Suppress -Warray-bounds false positive in RCLASS_WRITE_SUPER (#16990)HEADmaster
After 4bb1977b78 switched RCLASS_PRIME_CLASSEXT_WRITABLE_P to FL_TEST_RAW, GCC lost the RB_FL_ABLE-derived hint that klass is not a special const, and started warning that RCLASS_EXT_PRIME(klass) (used by the inlined RCLASS_WRITE_SUPER in class_associate_super) could yield a near-zero pointer. Make the existing VM_ASSERT(klass != 0) precondition visible to the optimizer via RBIMPL_ASSUME so the warning goes away without re-introducing the FL_TEST overhead. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'internal')
-rw-r--r--internal/class.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/class.h b/internal/class.h
index 4366223f84..0773dbad95 100644
--- a/internal/class.h
+++ b/internal/class.h
@@ -297,6 +297,7 @@ RCLASS_PRIME_CLASSEXT_WRITABLE_P(VALUE klass)
{
VM_ASSERT(klass != 0, "klass should be a valid object");
VM_ASSERT_BOXABLE_TYPE(klass);
+ RBIMPL_ASSUME(klass != 0);
return FL_TEST_RAW(klass, RCLASS_PRIME_CLASSEXT_WRITABLE);
}