Re: Fix division by zero to throw exception
| From: | Andrea Faulds | Date: | Fri, 03 Apr 2015 22:13:00 +0000 |
| Subject: | Re: Fix division by zero to throw exception | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85731@lists.php.net to get a copy of this message | ||
> 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. :)
--
Andrea Faulds
http://ajf.me/