Skip to content

Commit

Permalink
[libcxx] Use integer division
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petrhosek committed Mar 29, 2021
1 parent 45fd7c0 commit bc4d3ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libcxx/utils/gdb/libcxx/printers.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def to_string(self):

def _list_it(self):
for bit in range(self.bit_count):
word = math.floor(bit / self.bits_per_word)
word = bit // self.bits_per_word
word_bit = bit % self.bits_per_word
if self.values[word] & (1 << word_bit):
yield ("[%d]" % bit, 1)
Expand Down

0 comments on commit bc4d3ca

Please sign in to comment.