Details
-
Bug
-
Resolution: Fixed
-
P4
-
9
-
b14
-
generic
-
generic
Description
The current definition of left_n_bits is
#define left_n_bits(n) \
(right_n_bits(n) << (((n) >= BitsPerWord) ? 0 : (BitsPerWord - (n))))
When n == 0, this reduces to
(right_n_bits(0) << BitsPerWord)
According to C++03 5.8/2, the behavior of a shift expression is undefined if the right operand is greater than or equal to the length in bits of the promoted left operand. So a shift by BitsPerWord invokes undefined behavior.
#define left_n_bits(n) \
(right_n_bits(n) << (((n) >= BitsPerWord) ? 0 : (BitsPerWord - (n))))
When n == 0, this reduces to
(right_n_bits(0) << BitsPerWord)
According to C++03 5.8/2, the behavior of a shift expression is undefined if the right operand is greater than or equal to the length in bits of the promoted left operand. So a shift by BitsPerWord invokes undefined behavior.
Attachments
Issue Links
- relates to
-
JDK-8233144 undefined behavior: signed integer overflow
-
- Open
-
-
JDK-8169039 Add unit tests for BitMap search operations
-
- Resolved
-
-
JDK-8178352 BitMap::get_next_zero_offset may give wrong result on Mac
-
- Resolved
-