Bug#679123: tcc: Incorrect shift result type with 64-bit ABI

2012-07-06 Thread Vincent Lefevre
reopen 679123
found 679123 0.9.26~git20120612.ad5f375-4
thanks

On 2012-06-27 13:37:38 +0200, Vincent Lefevre wrote:
 I've written a patch (attached).

It was incorrect on an unsigned short first argument.
A new patch is available here:

http://repo.or.cz/w/tinycc.git/commitdiff/d27a0b35482b907357d76a9db4e0b18ec89cf979

and the tests (themselves tested with gcc) here:

http://repo.or.cz/w/tinycc.git/commitdiff/09b98a42a38b3c0bd6eb9de99dc8a4fc3951a760

-- 
Vincent Lefèvre vinc...@vinc17.net - Web: http://www.vinc17.net/
100% accessible validated (X)HTML - Blog: http://www.vinc17.net/blog/
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#679123: tcc: Incorrect shift result type with 64-bit ABI

2012-06-27 Thread Vincent Lefevre
Note: this bug has been found when testing GNU MPFR. It is silently
built incorrectly with tcc due to the use of sizeof(), which is
equivalent to an unsigned long, in shift-count sub-expressions.
This can be seen with make check, where many MPFR tests fail.

-- 
Vincent Lefèvre vinc...@vinc17.net - Web: http://www.vinc17.net/
100% accessible validated (X)HTML - Blog: http://www.vinc17.net/blog/
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#679123: tcc: Incorrect shift result type with 64-bit ABI

2012-06-27 Thread Vincent Lefevre
tags 679123 patch upstream
thanks

I've written a patch (attached).

Could you please look at it before the freeze?

It solves the problems with the testcase and with MPFR, but I've
tested it only on amd64.

-- 
Vincent Lefèvre vinc...@vinc17.net - Web: http://www.vinc17.net/
100% accessible validated (X)HTML - Blog: http://www.vinc17.net/blog/
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
--- a/tccgen.c  2012-06-12 15:45:13.0 +0200
+++ b/tccgen.c  2012-06-27 12:49:13.0 +0200
@@ -1678,6 +1678,9 @@
 (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;


Bug#679123: tcc: Incorrect shift result type with 64-bit ABI

2012-06-27 Thread Thomas Preud'homme
Le mercredi 27 juin 2012 13:37:38, vous avez écrit :
 tags 679123 patch upstream
 thanks
 
 I've written a patch (attached).
 
 Could you please look at it before the freeze?

That's my goal but I'm quite busy unfortunetely. I'll do my best.

 
 It solves the problems with the testcase and with MPFR, but I've
 tested it only on amd64.

Cheers.


signature.asc
Description: This is a digitally signed message part.


Bug#679123: tcc: Incorrect shift result type with 64-bit ABI

2012-06-26 Thread Vincent Lefevre
Package: tcc
Version: 0.9.26~git20120612.ad5f375-3
Severity: important
Forwarded: 
http://lists.nongnu.org/archive/html/tinycc-devel/2012-06/msg00037.html

The behavior on the following program is incorrect with tcc:

#include stdio.h

#define M1 (1  (int) 1)
#define M2 (1  (unsigned int) 1)
#define M3 (1  (long) 1)
#define M4 (1  (unsigned long) 1)
#define M5 (1  (long long) 1)
#define M6 (1  (unsigned long long) 1)

#define OUT(M) \
  printf (%d %s\n, (int) sizeof(M), -M  0 ? signed : unsigned)

int main (void)
{
  OUT(M1);
  OUT(M2);
  OUT(M3);
  OUT(M4);
  OUT(M5);
  OUT(M6);
  return 0;
}

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.

Thus the type of the shift result should be int in the 6 cases.

Correct behavior (with gcc):
4 signed
4 signed
4 signed
4 signed
4 signed
4 signed

Incorrect behavior (with tcc):
4 signed
4 unsigned
8 signed
8 unsigned
8 signed
8 unsigned

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages tcc depends on:
ii  dpkg  1.16.4.3
ii  install-info  4.13a.dfsg.1-10
ii  libc6 2.13-33

Versions of packages tcc recommends:
ii  libc6-dev [libc-dev]  2.13-33

tcc suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org