DragonFly kernel List (threaded) for 2007-11
DragonFly BSD
DragonFly kernel List (threaded) for 2007-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

GCC-4 compiler bug


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2007 13:23:30 -0800 (PST)

    GCC-4.1.2 is not properly handling signed 64 bit rollovers.  It's
    not doing it properly for 32 bit rollovers either.

    This program should generate an "X" when run.  It doesn't.

int
main(int ac, char **av)
{
        int64_t n = 0x7FFFFFFFFFFFFFFFLL;

        if (n + (128 * 1024) + 1 < n)
                printf("X\n");
}

    If I replace the calculation with an assigned variable, it works:

int
main(int ac, char **av)
{
        int64_t n = 0x7FFFFFFFFFFFFFFFLL;
        int64_t o = n + (128 * 1024) + 1;

        if (o < n)
                printf("X\n");
}


test28# cc -v
Using built-in specs.
Target: 
Configured with: DragonFly/i386 system compiler
Thread model: posix
gcc version 4.1.2 (DragonFly)

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>




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