tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] 64-bit int division does not work correct.


From: Thomas Mertes
Subject: [Tinycc-devel] 64-bit int division does not work correct.
Date: Thu, 3 Mar 2016 10:11:26 +0100

Hi development team,

I found a bug in tcc version 0.9.26 (x86-64 Win64) under Windows.
Integer division of the smallest or biggest 64-bit value by the
smallest or biggest 32-bit value does not work correct.

You can see that with the attached example program (tcc_err2.c).

If I do compile tcc_err2.c with tcc and execute it I get the following:

C:\seed7\src>tcc -o tcc_err2.exe tcc_err2.c

C:\seed7\src>tcc_err2
sizeof(long): 4
sizeof(long long): 8
Using long long.
-9223372036854775808LL / -2147483649LL =                    0 expected:  
4294967294
-9223372036854775808LL / -2147483648LL =                    0 expected:  
4294967296
 9223372036854775807LL / -2147483649LL =                    0 expected: 
-4294967294
 9223372036854775807LL / -2147483648LL =                    0 expected: 
-4294967295
-9223372036854775808LL % -2147483649LL = -9223372036854775808 expected:         
 -2
-9223372036854775808LL % -2147483648LL = -9223372036854775808 expected:         
  0
 9223372036854775807LL % -2147483649LL =  9223372036854775807 expected:         
  1
 9223372036854775807LL % -2147483648LL =  9223372036854775807 expected:  
2147483647

If I compile tcc_err2.c with gcc and execute it everything is okay:

C:\seed7\src>gcc -o tcc_err2.exe tcc_err2.c

C:\seed7\src>tcc_err2
sizeof(long): 4
sizeof(long long): 8
Using long long.
-9223372036854775808LL / -2147483649LL =           4294967294 expected:  
4294967294
-9223372036854775808LL / -2147483648LL =           4294967296 expected:  
4294967296
 9223372036854775807LL / -2147483649LL =          -4294967294 expected: 
-4294967294
 9223372036854775807LL / -2147483648LL =          -4294967295 expected: 
-4294967295
-9223372036854775808LL % -2147483649LL =                   -2 expected:         
 -2
-9223372036854775808LL % -2147483648LL =                    0 expected:         
  0
 9223372036854775807LL % -2147483649LL =                    1 expected:         
  1
 9223372036854775807LL % -2147483648LL =           2147483647 expected:  
2147483647

I home thet it is possible to fix this bug.

Regards
Thomas Mertes

--
Seed7 Homepage:  http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

Attachment: tcc_err2.c
Description: Text document


reply via email to

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