Hi all,

 

Playing with clock_gettime and uint64_t/int64_t on RPi (ARM), I discovered
uint64_t => double conversion bug :

NOTE: tcc is compiled using --with-libgcc

 

#include <stdint.h>

#include <stdio.h>

 

static uint64_t x1 = 123456789;

static uint32_t x2 = 123456789;

int

main()

{

        double d1 = (double)x1;

        double d2 = (double)x2;

        printf("d = %g\n", d1);

        printf("%d => %g\n", (uint32_t)x1, d1); // x1 is not 0

        printf("%d => %g\n", (uint32_t)x2, d2); // works if x2 is uint32_t

}

 

$ tcc foo.c && ./a.out

d = 0

123456789 => 0

123456789 => 1.23457e+08

 

Changing uint64_t to int64_t produces the same bug.

 

Christian

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to