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]

Re: GCC-4 compiler bug


From: Jeremy Messenger <mezz7@xxxxxxx>
Date: 28 Nov 2007 05:58:31 GMT

On Tue, 27 Nov 2007 13:23:30 -0800, Matthew Dillon wrote:

> 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");
> }

Here on FreeBSD 7.0-BETA2 i386 (RELENG_7) comes with GCC 4.2.1, I get 
this:

---------------------------------------------
% cc test.c -o test
% ./test
X
% cc -v
Using built-in specs.
Target: i386-undermydesk-freebsd
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 4.2.1 20070719  [FreeBSD]
---------------------------------------------

Maybe update GCC will helping?

Cheers,
Mezz

>     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]