davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
421 stars 59 forks source link

i80: smallconst2 rules don't take negative numbers into account #159

Closed davidgiven closed 5 years ago

davidgiven commented 5 years ago

The smallconst2 rules all assume that the constant is 8-bits wide and don't sign extend it, causing incorrect results when the constant is negative.

Trivial test case:

int foo(int n) { printf("~ is %d\n", n & ~1); }