Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85727 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81946 invoked from network); 3 Apr 2015 21:13:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2015 21:13:33 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.46 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.46 mail-yh0-f46.google.com Received: from [209.85.213.46] ([209.85.213.46:34328] helo=mail-yh0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 00/67-23347-B720F155 for ; Fri, 03 Apr 2015 16:13:33 -0500 Received: by yhla23 with SMTP id a23so15802266yhl.1 for ; Fri, 03 Apr 2015 14:13:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=H78EXBY0rqmDUg/MBxudcryapr8G/OBHEQOk8IQtbFA=; b=KtuHYw5CFJD9nbjnlyq5L+IsDjmvCH+MG3k5xPBw10g7iZwzmwMZFTtxrsaoHVa8yG VtFX4uK6lv4IIU3pK/sVJ8S5kP9WEs1YV0bAgFK1D13Y1LjZ+fsqLO8hX3HWXuGFAfrm zqq+/rfnfJjZVXBdXHYTGTFOTd1Sm0hryiqGubjAPnPaUxaC6lhwb+FCbIyPycgvduOO mTonOMlpr/J+P4tPbISpwOsIX5ThMBaK/CvMf2reHKCv6iPWDw1GjhVQ+SnVWr0H/QZP 2YQslvxJ7aP28i4OLZSeCIoTdT3Oi4rDIj8xIF3E6vH+GpRL6jPk7/JYCrHbORn39Ve/ 42FQ== X-Gm-Message-State: ALoCoQmTBpwqCZJXrpcK2oJehKc8MhYBqqNv+/wS3pXH1j9Rhadce7YMsdqVPNJjMmkdetMUaEnNygcuqcBhyZhlOCNM1sDSFOr9vBcYugu7C9519rlwQsaiv9RM9wwdBlPa9U+QeFqB8P5ST9PcCk5fWU8onmvKVg== MIME-Version: 1.0 X-Received: by 10.52.137.235 with SMTP id ql11mr2355186vdb.49.1428095609398; Fri, 03 Apr 2015 14:13:29 -0700 (PDT) Received: by 10.52.248.36 with HTTP; Fri, 3 Apr 2015 14:13:29 -0700 (PDT) In-Reply-To: <3932E76B-DC75-40CD-8B1A-B84F387707CC@ajf.me> References: <33BCE1D0-BA6D-464C-B23D-69AF71356111@ajf.me> <3932E76B-DC75-40CD-8B1A-B84F387707CC@ajf.me> Date: Sat, 4 Apr 2015 00:13:29 +0300 Message-ID: To: Andrea Faulds Cc: PHP Internals , Nikita Popov Content-Type: multipart/alternative; boundary=bcaec51b9a5180fec30512d86b7e Subject: Re: Fix division by zero to throw exception From: dmitry@zend.com (Dmitry Stogov) --bcaec51b9a5180fec30512d86b7e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Apr 3, 2015 at 11:59 PM, Andrea Faulds wrote: > Hi, > > > On 3 Apr 2015, at 20:46, Dmitry Stogov wrote: > > > > 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. > > I don=E2=80=99t think opposite-direction shifts would work well for a few= reasons. > I don=E2=80=99t believe this is normal behaviour in other languages, for = one. > Another issue is that << and >> are not actually opposites, they have > different behaviour with respect to signs, so there=E2=80=99d be ambiguit= y as to > what $x << -$y means (is it the same as $x >> $y, or does it deal > differently with signs?). Negative shifts being used are usually the resu= lt > of mistakes, as well, so you want to inform the user. > > The main problem, though, is that we previously did something different i= f > the shift is negative. Having it now produce a warning, means you=E2=80= =99ll see > error messages when you run existing code. But shifting in the opposite > direction might change the behaviour of existing code silently > > I think the most sensible solution would be to make negative shifts > produce an exception, since they=E2=80=99re really an error, an unsupport= ed > operation. I made them be a warning + return FALSE just because it matche= d > division. But that=E2=80=99s not ideal and I=E2=80=99d be fine if it was = replaced. > OK. Exception is fine. So the summary: 1) division by zero produces a warning and +/-INF IS_DOUBLE. Compile-time evaluation is disabled. 2) Negative shift produces Exception.Compile-time evaluation is disabled. 3) Modulo by zero produces Exception.Compile-time evaluation is disabled. Everything right? I'm going to implement this on Monday. Thanks. Dmitry. > > Thanks. > > -- > Andrea Faulds > http://ajf.me/ > > > > > --bcaec51b9a5180fec30512d86b7e--