Michael Somos wrote:
There is a bug in shift generation. Notice the "1UL". If it is just "1"
instead, the code is "sar" as expected. Here is script showing difference :
[...]
int i;
int main(void){ return i >> 1UL ; }
A quick fix:
--- tcc.c 17 Apr 2005 13:15:54 -0000 1.170
+++ tcc.c 20 Jun 2005 12:40:18 -0000
@@ -5600,7 +5600,7 @@
/* XXX: currently, some unsigned operations are explicit, so
we modify them here */
if (t & VT_UNSIGNED) {
- if (op == TOK_SAR)
+ if (op == TOK_SAR && (t1 & VT_UNSIGNED))
op = TOK_SHR;
else if (op == '/')
op = TOK_UDIV;
Nevertheless you should keep in mind that for both C89 and C99 the
result of a signed right shift is undefined (which was a silly decision
IMO) so the current behaviour is probably not stricly wrong (although
most likely not the indented one).
Felix
_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel