bit_val was being used directly in the statement in return. If type B had fewer bits...
authorAli Saidi <saidi@eecs.umich.edu>
Wed, 9 May 2007 16:01:31 +0000 (12:01 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Wed, 9 May 2007 16:01:31 +0000 (12:01 -0400)
src/base/bitfield.hh:
    bit_val was being used directly in the statement in
    return. If type B had fewer bits than last, bit_val << last would get
    the wrong answer.

--HG--
extra : convert_revision : cbc43ccd139f82ebbd65f30af5d05b87c4edac64

src/base/bitfield.hh

index 69cce22459aa11014958ef6c78a39d176ce27e72..518bad6b87ad64fcbcad7203f8dc3364974ac01f 100644 (file)
@@ -96,8 +96,9 @@ inline
 T
 insertBits(T val, int first, int last, B bit_val)
 {
+    T t_bit_val = bit_val;
     T bmask = mask(first - last + 1) << last;
-    return ((bit_val << last) & bmask) | (val & ~bmask);
+    return ((t_bit_val << last) & bmask) | (val & ~bmask);
 }
 
 /**