tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Another ARM (RPi) compiler bug


From: Christian Jullien
Subject: [Tinycc-devel] Another ARM (RPi) compiler bug
Date: Sun, 3 Feb 2013 22:14:16 +0100

Wrong double -> int conversion when double is < 0

#include <stdio.h>

int
main()
{
        // Ok if d >0

        {
        double d = 413.55;
        long l = (long)d;
        int i = (int)d;
        printf("d=%f, i=%d (OK), l=%ld (OK)\n", d, i, l);
        }

        // BUG if d <0

        {
        double d = -413.55;
        long l = (long)d;
        int i = (int)d;
        printf("d=%f, i=%d (BUG), l=%ld (BUG)\n", d, i, l);
        }
}

jullien~/openlisp/src $ tcc foo.c && ./a.out
d=413.550000, i=414 (OK), l=414 (OK)
d=-413.550000, i=0 (BUG), l=0 (BUG)




reply via email to

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