Closed yodalee closed 8 years ago
About this bug, I can make shift as a special case when parsing. In current implementation, amacc will generate instruction: left shift a negative number. Since ARM left shift cannot recognize negative number, so left shift a negative number will cause left shift many times and the result 0.
I think this issue can be closed. gcc
output 2 since it optimize out the left shift. The following code:
scanf("%d", &v);
printf("%d", 4<<v);
with v=-1 will also get 0
with gcc.
cc @jserv
In test file
tests/shift.c
, the execution result of following code:is
4 << -1 = 0
, whilegcc
output4 << -1 = 2
It is possible that left shift of negative number is handled like unsigned number, thus wipe out all bits.