[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] tcc 0.9.23 shift generation bug
From: |
Felix Nawothnig |
Subject: |
Re: [Tinycc-devel] tcc 0.9.23 shift generation bug |
Date: |
Mon, 20 Jun 2005 14:44:24 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050317) |
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