summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-19 18:45:26 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-19 22:55:42 +0900
commit412e3c7a8db275567eaceece6c48dde3aedf2ae6 (patch)
treec67ba76d040fb1b7a312165b99f5b95300d797b5 /include
parent86096a91d55f72620e0f8ca8634da5fa342dc35b (diff)
Assert for RTEST that Qnil and Qfalse differ just 1 bit
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6589
Diffstat (limited to 'include')
-rw-r--r--include/ruby/internal/special_consts.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/ruby/internal/special_consts.h b/include/ruby/internal/special_consts.h
index 38934e4da3..70276278eb 100644
--- a/include/ruby/internal/special_consts.h
+++ b/include/ruby/internal/special_consts.h
@@ -136,6 +136,7 @@ static inline bool
RB_TEST(VALUE obj)
{
/*
+ * if USE_FLONUM
* Qfalse: ....0000 0000
* Qnil: ....0000 1000
* ~Qnil: ....1111 0111
@@ -143,6 +144,14 @@ RB_TEST(VALUE obj)
* ----------------------------
* RTEST(v) ....xxxx 0xxx
*
+ * if ! USE_FLONUM
+ * Qfalse: ....0000 0000
+ * Qnil: ....0000 0100
+ * ~Qnil: ....1111 1011
+ * v ....xxxx xxxx
+ * ----------------------------
+ * RTEST(v) ....xxxx x0xx
+ *
* RTEST(v) can be 0 if and only if (v == Qfalse || v == Qnil).
*/
return obj & ~RUBY_Qnil;