From 240064c03bbc4264ff972f4dbd2d0e2f6d4222c7 Mon Sep 17 00:00:00 2001 From: Vincent Lefevre Date: Wed, 27 Jun 2012 13:31:44 +0200 Subject: [PATCH] Incorrect shift result type with 64-bit ABI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2012-06-26 15:07:57 +0200, Vincent Lefevre wrote: > ISO C99 TC3 says: [6.5.7#3] "The integer promotions are performed on > each of the operands. The type of the result is that of the promoted > left operand." I've written a patch (attached). Now the shift problems no longer occur with the testcase and with GNU MPFR's "make check". -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) --- tccgen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tccgen.c b/tccgen.c index 7295267..26a5781 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1678,6 +1678,9 @@ ST_FUNC void gen_op(int op) (op < TOK_ULT || op > TOK_GT)) tcc_error("invalid operands for binary operation"); goto std_op; + } else if (op == TOK_SHR || op == TOK_SAR || op == TOK_SHL) { + t = (bt1 == VT_LLONG ? VT_LLONG : VT_INT) | (t1 & VT_UNSIGNED); + goto std_op; } else if (bt1 == VT_LLONG || bt2 == VT_LLONG) { /* cast to biggest op */ t = VT_LLONG;