Re: Fix division by zero to throw exception
| From: | Dmitry Stogov | Date: | Fri, 03 Apr 2015 19:46:56 +0000 |
| Subject: | Re: Fix division by zero to throw exception | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85722@lists.php.net to get a copy of this message | ||
On Fri, Apr 3, 2015 at 10:10 PM, Andrea Faulds <ajf@ajf.me> wrote:
> Hi Dmitry,
>
> > On 3 Apr 2015, at 20:04, Dmitry Stogov <dmitry@zend.com> wrote:
> >
> > 2) Very similar weird behavior was introduced for shift with negative
> offsets. I also propose to change it in the same way (Fatal error at
> compile-time, Exception in run-time).
> >
> > Any thoughts? objections?
>
> For consistency with IEEE 754, shouldn't we produce INF on a division by
> zero, at least for floats (but probably integers too because of weak
> typing)? I don't think producing a warning is an issue, but FALSE isn't the
> right value to produce.
>
INF is definitely better than FALSE :)
>
> However there should be a compile-time solution. Maybe, if a division by
> zero happens, don't evaluate the expression at compile-time?
>
Yes. This should be possible.
Keeping WARNING, returning INF and preventing compile-time evaluation is a
consistent solution for me.
May be you'll also suggest something regarding bitwise shifts with negative
offset?
Allowing negative offsets using opposite directions would fix
inconsistency, but I remember, you didn't like it.
May be keep WARNING (Bit shift by negative number) and then perform shift
in another direction?
+ disable negative shifts at compile-time.
Thanks. Dmitry.
>
> Thanks.
>
> --
> Andrea Faulds
> http://ajf.me/