Skip to content

Commit bc4d3ca

Browse files
committed
[libcxx] Use integer division
In Python 3, math.floor returns int when both arguments are ints. In Python 2, math.floor returns float. This leads to a failure because the result of math.floor is used as an array index. While Python 2 is on its way out, it's still used in some places so use an integer division instead. Differential Revision: https://reviews.llvm.org/D99520
1 parent 45fd7c0 commit bc4d3ca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libcxx/utils/gdb/libcxx/printers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def to_string(self):
439439

440440
def _list_it(self):
441441
for bit in range(self.bit_count):
442-
word = math.floor(bit / self.bits_per_word)
442+
word = bit // self.bits_per_word
443443
word_bit = bit % self.bits_per_word
444444
if self.values[word] & (1 << word_bit):
445445
yield ("[%d]" % bit, 1)

0 commit comments

Comments
 (0)