Re: Re: Fix division by zero to throw exception

From: Date: Sat, 04 Apr 2015 18:40:36 +0000
Subject: Re: Re: Fix division by zero to throw exception
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-85733@lists.php.net to get a copy of this message
Am 04.04.2015 um 00:13 schrieb Andrea Faulds:
On 3 Apr 2015, at 23:08, Dmitry Stogov <dmitry@zend.com> wrote: On Apr 4, 2015 12:34 AM, "Nikita Popov" <nikita.ppv@gmail.com> wrote:
Don't think we need to disable compile-time evaluation for 2) and 3). It'll just end up being a compile error in that case. I think if you have 1 % 0 occurring in your code literally, it's better to have the compile fail rather than getting (or not getting) a runtime exception.
This is even easier. Andrea, what do you think?
I was wondering if that might cause problems if you have a large codebase and some unfixed errors in a few places. If the code isn’t being run, only compiled, then it’d be unnecessary pain. However, the chances of a codebase having numerous undetected divisions by zero, that are obvious at compile-time, aren’t very high. So, failing at compile-time is fine. And, to save another email, I agree with the four items in your summary. Exceptions for negative shift, modulo/intdiv by zero, normal division by zero is +/-INF. :) If the normal division by zero produces +/- INF it's a valid calculation and shouldn't trigger a warning else it should end up in an exception, too.
-- Andrea Faulds http://ajf.me/


« previous php.internals (#85733) next »