Hi,
The behavior on the following program is incorrect with Debian's
tcc (at least up to 0.9.26~git20120612.ad5f375-3) on x86_64
(64-bit ABI).
#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:
4 signed
4 signed
4 signed
4 signed
4 signed
4 signed
Incorrect behavior (with 64-bit tcc 0.9.26~git20120612.ad5f375-3):
4 signed
4 unsigned
8 signed
8 unsigned
8 signed
8 unsigned
--
Vincent Lefèvre <[email protected]> - 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)
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel