summaryrefslogtreecommitdiff
path: root/regint.h
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 08:50:01 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 08:50:01 +0000
commit1efb3c31b731e99627bbc0da13dfd3463bb67c67 (patch)
treef6258144a4e2509c34fac5fcda8291547951b4dc /regint.h
parent0f67a3bb3171c98770c7a5de8559636d2551a3b8 (diff)
downloadruby-1efb3c31b731e99627bbc0da13dfd3463bb67c67.tar.gz
* Avoid undefined behaviors found by gcc -fsanitize=undefined.
gcc (Debian 4.9.1-16) 4.9.1 * include/ruby/ruby.h (INT2FIX): Avoid undefined behavior. * node.h (nd_set_line): Ditto. * pack.c (encodes): Ditto. (pack_unpack): Ditto. * regint.h (BIT_STATUS_AT): Ditto. (BS_BIT): Ditto. * time.c (time_mdump): Ditto. (time_mload): Ditto. * vm_core.h (VM_FRAME_MAGIC_MASK): Ditto. * vm_trace.c (recalc_add_ruby_vm_event_flags): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regint.h')
-rw-r--r--regint.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/regint.h b/regint.h
index 3abc8809c9..855bedd7f9 100644
--- a/regint.h
+++ b/regint.h
@@ -392,7 +392,7 @@ typedef unsigned int BitStatusType;
#define BIT_STATUS_CLEAR(stats) (stats) = 0
#define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
#define BIT_STATUS_AT(stats,n) \
- ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1))
+ ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & ((BitStatusType)1 << n)) : ((stats) & 1))
#define BIT_STATUS_ON_AT(stats,n) do {\
if ((n) < (int )BIT_STATUS_BITS_NUM) \
@@ -468,7 +468,7 @@ typedef Bits* BitSetRef;
} while (0)
#define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
-#define BS_BIT(pos) (1 << ((int )(pos) % BITS_IN_ROOM))
+#define BS_BIT(pos) (1U << ((int )(pos) % BITS_IN_ROOM))
#define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
#define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)