tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tcc 0.9.23 shift generation bug


From: Zdenek Pavlas
Subject: Re: [Tinycc-devel] tcc 0.9.23 shift generation bug
Date: Mon, 05 Sep 2005 10:48:59 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050718 Debian/1.7.8-1sarge1

Fabrice Bellard wrote:
Zdenek Pavlas wrote:

Signed shifts of signed integers should not give unsigned results.
This fix is probably a better one.

--- tcc.c.orig  2005-06-18 00:09:15.000000000 +0200
+++ tcc.c       2005-06-28 12:17:44.472171840 +0200
@@ -5628,7 +5628,8 @@
         t = VT_INT;
         /* convert to unsigned if it does not fit in an integer */
         if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED) ||
-            (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED))
+            (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED) &&
+            (op != TOK_SAR))
             t |= VT_UNSIGNED;
     std_op:
         /* XXX: currently, some unsigned operations are explicit, so


OK for the bug, but this fix is still incorrect : the shift operations should be handled separately because they keep the type of the first operand.

Isn't this enough?

--- tcc.c.orig  2005-06-18 00:09:15.000000000 +0200
+++ tcc.c       2005-06-28 12:17:44.472171840 +0200
@@ -5628,7 +5628,8 @@
         t = VT_INT;
         /* convert to unsigned if it does not fit in an integer */
         if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED) ||
-            (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED))
+            (t2 & (VT_BTYPE | VT_UNSIGNED)) == (VT_INT | VT_UNSIGNED) &&
+            (op != TOK_SAR) && (op != TOK_SHL))
             t |= VT_UNSIGNED;
     std_op:
         /* XXX: currently, some unsigned operations are explicit, so

--
Zdenek Pavlas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]