Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85722 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66258 invoked from network); 3 Apr 2015 19:47:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2015 19:47:00 -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.160.178 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.160.178 mail-yk0-f178.google.com Received: from [209.85.160.178] ([209.85.160.178:34119] helo=mail-yk0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/65-23347-33EEE155 for ; Fri, 03 Apr 2015 14:46:59 -0500 Received: by ykft189 with SMTP id t189so9731460ykf.1 for ; Fri, 03 Apr 2015 12:46:56 -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=IBVGq6QcVO+iGH9R/E0pCtxbaZ4OoXzo3u8JTQ8Hmgc=; b=B+i2jUiACw/QmAVFU6crXiCkR2qpszqj6HzCPGcbIKdIv4/7Sbk4tOiMs3lgnER+7B Ho4EonQ0tUtn5YG/vRiIyn6wMxOdQGr7VZkKr9YDpkqb3GjSALzdBRk7ZurVMzHdgA7I E99qtyjsds+fGPLKCjHSez4vGlFrM0y4g//uFvOrD5r1ugCxsgW5ugvjBVJnbgGE6G1o p5nKUOQO4w4JDy2C3exEYwNF1RMsqPLw9XZ0V5sDYGEenLXBRLerLVRWJ14b7400TvQf eKa29sSpFg6boUShh5ygelL0EXLPakX87mWEBuq+VJJbnCQJVuw+TJdynkc3Ro1WeCvN LMdQ== X-Gm-Message-State: ALoCoQnjN2eWzapfflJ97t5o8ypqu34vWeTvLya7w6WXBXkcabU5I2OhlCEP/8D01nc2V18/bVUr1vuGPRlbce7q3sMOIBCIs/LTPKjR7t0LZSv6LycW51/9t4Uby60G16m97Ntv8LexQwdPe5+x7b4WqQZJbxNPqA== MIME-Version: 1.0 X-Received: by 10.52.171.199 with SMTP id aw7mr2159837vdc.65.1428090416441; Fri, 03 Apr 2015 12:46:56 -0700 (PDT) Received: by 10.52.248.36 with HTTP; Fri, 3 Apr 2015 12:46:56 -0700 (PDT) In-Reply-To: <33BCE1D0-BA6D-464C-B23D-69AF71356111@ajf.me> References: <33BCE1D0-BA6D-464C-B23D-69AF71356111@ajf.me> Date: Fri, 3 Apr 2015 22:46:56 +0300 Message-ID: To: Andrea Faulds Cc: PHP Internals , Nikita Popov Content-Type: multipart/alternative; boundary=089e0160bd14fac4cd0512d735bb Subject: Re: Fix division by zero to throw exception From: dmitry@zend.com (Dmitry Stogov) --089e0160bd14fac4cd0512d735bb Content-Type: text/plain; charset=UTF-8 On Fri, Apr 3, 2015 at 10:10 PM, Andrea Faulds wrote: > Hi Dmitry, > > > On 3 Apr 2015, at 20:04, Dmitry Stogov 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/ --089e0160bd14fac4cd0512d735bb--