diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-11-02 02:39:41 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-11-02 02:41:30 +0200 |
commit | 039887a0ac9bd02cfd84e4792d3d21a78bc06a7f (patch) | |
tree | 009fccb2375d12d3bdc0302e346b6901753bd6d6 /tests/basics/int_small.py | |
parent | a58713a899b7df5b291e868d2553b2333c0b3dc9 (diff) | |
download | micropython-039887a0ac9bd02cfd84e4792d3d21a78bc06a7f.tar.gz micropython-039887a0ac9bd02cfd84e4792d3d21a78bc06a7f.zip |
py: Fix bug with right-shifting small ints by large amounts.
Undefined behavior in C, needs explicit check.
Diffstat (limited to 'tests/basics/int_small.py')
-rw-r--r-- | tests/basics/int_small.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/int_small.py b/tests/basics/int_small.py index 102dac8ae7..1b2c983e23 100644 --- a/tests/basics/int_small.py +++ b/tests/basics/int_small.py @@ -48,3 +48,17 @@ a -= 1 print(a) # This would overflow #a -= 1 + + +# Shifts to big amounts are undefined behavior in C and is CPU-specific + +# These are compile-time constexprs +print(1 >> 32) +print(1 >> 64) +print(1 >> 128) + +# These are runtime calcs +a = 1 +print(a >> 32) +print(a >> 64) +print(a >> 128) |