(bug caused by tcc intristics)
commit310e3b428cfd181b51723276e6563b90d670da06
authorKyryl Melekhin <k.melekhin@gmail.com>
Tue, 8 Sep 2020 22:12:01 +0000 (8 22:12 +0000)
committerKyryl Melekhin <k.melekhin@gmail.com>
Tue, 8 Sep 2020 22:12:01 +0000 (8 22:12 +0000)
tree43b82fe3123cc8e459ab143b41e2e27cea121682
parent55f8963dfab5c543f7f34589d3ef9d3f2da3db14
(bug caused by tcc intristics)
reproduce bug:
$ ./configure --cc=gcc
$ make
$ make install
(OK)
run a test:

extern int printf(const char *str, ...);
int main()
{
        int t2 = (int)(-1.847759065f * 4096);
        printf("%d\n", t2);
}

$ tcc test.c
$ ./a.out
$ -7568
(OK)

(self compiled now)
$ ./configure --cc=tcc
$ make
$ make install
(OK)

$ tcc test.c
$ ./a.out
$ 7568
(WRONG!!!)

why:
gcc does not have intristics for
uint to long double conversion
therefore it does cast implicitly, so
the sign bit is preserved, but this does
not happen when __fixunsxfdi is called
because tcc was bootstrapped.

solution:
force cast to int64 and preserve the
sign bit.

side effects:
not found.
tccgen.c