There seem to be a bug which causes a data loses during
the evaluation of some complex expressions.
The program that demonstrates the bug, is attached.
Also here it is:
unsigned char p;
p = SBUF + 13;
c = 2 | ((int)1 << p);
The result is that c==2.
The asm code in question follows:
;shift.c:9: c = 2 | ((int)1 << p);
--> There might be no cast to byte <---
mov (_c + 1),#0x00
--> so it was casted, the higher byte is lost <---
;shift.c:10: return c;
The strange thing here is that the expression
c = (1 << p);
gets evaluated correctly, but
c = (int)2 | (1 << p);
is not and only
c = (int)2 | ((int)1 << p);
is evaluated correctly.
What puzzles me is that adding "2 |" affects the
evaluation of (1 << p) making it to loose the higher
byte, while it seems logical to expect that these
expressions are independant.
Log in to post a comment.