Re: [PHP-DEV] Integer overflows on float to int casts

2012-07-19 Thread Anatoliy Belsky
Hi Nikita, that's exactly the subject I've tripped over trying to fix (apparently wrong) the issue #62477. The ticket is about LimitIterator accepting only long for start and offset, but being able to accept an Iterator from userland accepting floats for positions. For instance, the snippet like

Re: [PHP-DEV] Integer overflows on float to int casts

2012-07-18 Thread Andrew Faulds
Cap it at INT_MAX, yeah, that seems reasonable. A notice seems reasonable but production servers displaying errors... devs will go mad :) On Jul 18, 2012 11:39 PM, "Nikita Popov" wrote: > Hi internals! > > When a large floating point number is cast to an integer we currently > have very low-level

[PHP-DEV] Integer overflows on float to int casts

2012-07-18 Thread Nikita Popov
Hi internals! When a large floating point number is cast to an integer we currently have very low-level C behavior (integer overflow and wraparound): $ /c/php-5.4.1/php -r 'var_dump((int) 40);' int(-294967296) $ /c/php-5.4.1/php -r 'var_dump((int) 60);' int(1705032704) As a fun