From 1efb3c31b731e99627bbc0da13dfd3463bb67c67 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 17 Oct 2014 08:50:01 +0000 Subject: * 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 --- regint.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'regint.h') 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) -- cgit v1.2.3