Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85718 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58503 invoked from network); 3 Apr 2015 19:29:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2015 19:29:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:38008] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/04-23347-81AEE155 for ; Fri, 03 Apr 2015 14:29:28 -0500 Received: by wiun10 with SMTP id n10so2582559wiu.1 for ; Fri, 03 Apr 2015 12:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=opZ6S9z+KH4nxmyJmqK/OBALZdfUfNR2eWYAQcwPRCU=; b=D31C50qK9eauNmC5IE88p67+pTJeGEei1oee7NIft1KmvuDXVr3Rj/l+ThIbYU28I4 c1SRkUbZpOUGb7eX/4nWbBvXOyEaxHkoeKSNb97lcifAfz5eJL+76z1riNIUfmpjbFOP 1c8b1NDOt6ECLMeY/O4gYPpMEostYBOuffYesHRxcRm4KicXoOZ+aUjf/qSZxkZ7eSkx KAlxYZrFKRbxHkmsevWKDhTLdvY87M0C/yVCHA31KyGy0rgM/W67GpXjnXZyzx7ul9cL p2sdGJgX6/Svsjpz4pEdcH//jkj6rIVywVRPKE+KZ3haPpFRVPospit5liq5kyjXF1la BN2w== MIME-Version: 1.0 X-Received: by 10.180.104.33 with SMTP id gb1mr36241357wib.33.1428089365648; Fri, 03 Apr 2015 12:29:25 -0700 (PDT) Received: by 10.27.85.216 with HTTP; Fri, 3 Apr 2015 12:29:24 -0700 (PDT) In-Reply-To: References: Date: Fri, 3 Apr 2015 21:29:24 +0200 Message-ID: To: Dmitry Stogov Cc: PHP Internals , Andrea Faulds Content-Type: multipart/alternative; boundary=f46d0442678e58d8ea0512d6f742 Subject: Re: Fix division by zero to throw exception From: nikita.ppv@gmail.com (Nikita Popov) --f46d0442678e58d8ea0512d6f742 Content-Type: text/plain; charset=UTF-8 On Fri, Apr 3, 2015 at 9:04 PM, Dmitry Stogov wrote: > 1) Division by zero behavior in PHP is really inconsistent. > It emits WARNING and returns FALLE. > > Note, that since PHP-5.6 division by zero may also occur in constant > expressions. They are compiled and evaluated only once (on first request) > and on next request WARNING is going to be hidden. > > $ cat div.php > class C { > const T = 5 / 0; > } > var_dump(C::T); > ?> > > $ sapi/cgi/php-cgi -q -T 3 div.php > PHP Warning: Division by zero in > /home/dmitry/php/php-master/CGI-DEBUG/div.php on line 3 > bool(false) > bool(false) > bool(false) > > I propose to change this into fatal error for division by zero at > compile-time and exception a run-time. > > 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? > I'm okay with making both of these exceptions. It's really weird if dividing two numbers you can suddenly end up with a boolean... Nikita --f46d0442678e58d8ea0512d6f742--