bd556b6996
There were two issues with the existing code: 1. "1 << i" is computed as a 32-bit number so would overflow when executed on 64-bit machines (when mp_uint_t is 64-bit). This meant that *args beyond 32 positions would not be handled correctly. 2. star_args must fit as a positive small int so that it is encoded correctly in the emitted code. MP_SMALL_INT_BITS is too big because it overflows a small int by 1 bit. MP_SMALL_INT_BITS - 1 does not work because it produces a signed small int which is then sign extended when extracted (even by mp_obj_get_int_truncated), and this sign extension means that any position arg after *args is also treated as a star-arg. So the maximum bit position is MP_SMALL_INT_BITS - 2. This means that MP_OBJ_SMALL_INT_VALUE() can be used instead of mp_obj_get_int_truncated() to get the value of star_args. These issues are fixed by this commit, and a test added. Signed-off-by: Damien George <damien@micropython.org> |
||
---|---|---|
.. | ||
bytecode_limit.py | ||
bytecode_limit.py.exp | ||
dict_copy.py | ||
dict_create_max.py | ||
dict_create.py | ||
fun_call_limit.py | ||
fun_call_limit.py.exp | ||
gc_trace.py | ||
list_sort.py | ||
qstr_limit.py | ||
qstr_limit.py.exp | ||
recursion.py | ||
recursive_data.py | ||
recursive_data.py.exp | ||
recursive_gen.py | ||
recursive_iternext.py | ||
recursive_iternext.py.exp |