Le 05/02/2013 08:54, Stas Malyshev a écrit :
> Hi!
>
>> - if (d > LONG_MAX) {
>> + if (d >= LONG_MAX) {
>> return (long)(unsigned long) d;
>> }
>> return (long) d;
>
> Could you please explain this one? I thought LONG_MAX is a largest
> permissible long value, why when d==LONG_MAX we need to convert?
LONG_MAX is the largest "unsigned" value.
We have different int/float conversion result on some arch (detected, at
least on ppc64).
long l = 0x7fffffffffffffff;
double d;
d = l;
d++;
printf("max+1=%lf, %ld, 0x%lx\n", d, (long)d, (long)d);
printf("max+1=%lf, %ld, 0x%lx\n", d, (long)(unsigned long)d,
(long)(unsigned long)d);
On x86_64
max+1=9223372036854786048.000000, -9223372036854775808, 0x8000000000000000
max+1=9223372036854786048.000000, -9223372036854765568, 0x8000000000002800
ON ppc64
max+1=9223372036854775808.000000, 9223372036854775807, 0x7fffffffffffffff
max+1=9223372036854775808.000000, -9223372036854775808, 0x8000000000000000
So we are in a really border case...
> Also, why this patch - which seems to be a BC break since it exhibits
> different behavior on 64-bit systems - needs to be in 5.4?
This patch doesn't change behavior on x86 arch.
It fixes 9 failed test on ppc64.
This is a very very old bug....
http://marc.info/?l=php-internals&m=109360955403511
(this patch wasn't correct, but the issue was the same)
Probably most people don't care in previous version (<5.4), where test
suite was in a quite awfull state.
Now than we have a good test suite (0 failed test in x86), I think it is
interesting to do some work on other arch (and hopefully, I have a ppc64
test machine available).
Regards,
Remi.
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php