Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95003 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6020 invoked from network); 10 Aug 2016 13:19:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2016 13:19:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=fsb@thefsb.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=fsb@thefsb.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thefsb.org designates 173.203.187.99 as permitted sender) X-PHP-List-Original-Sender: fsb@thefsb.org X-Host-Fingerprint: 173.203.187.99 smtp99.iad3a.emailsrvr.com Received: from [173.203.187.99] ([173.203.187.99:39920] helo=smtp99.iad3a.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/00-05841-CC92BA75 for ; Wed, 10 Aug 2016 09:19:08 -0400 Received: from smtp21.relay.iad3a.emailsrvr.com (localhost [127.0.0.1]) by smtp21.relay.iad3a.emailsrvr.com (SMTP Server) with ESMTP id D491140402; Wed, 10 Aug 2016 09:19:05 -0400 (EDT) X-Auth-ID: fsb@thefsb.org Received: by smtp21.relay.iad3a.emailsrvr.com (Authenticated sender: fsb-AT-thefsb.org) with ESMTPSA id BB4C8403FF; Wed, 10 Aug 2016 09:19:05 -0400 (EDT) X-Sender-Id: fsb@thefsb.org Received: from yossy.local (c-66-30-62-12.hsd1.ma.comcast.net [66.30.62.12]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA) by 0.0.0.0:587 (trex/5.7.1); Wed, 10 Aug 2016 09:19:05 -0400 To: Leigh , internals@lists.php.net References: Message-ID: <069eeb79-5fa7-0c52-515c-8be836d6fce2@thefsb.org> Date: Wed, 10 Aug 2016 09:18:56 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: BC break with rand() where min > max From: fsb@thefsb.org (Tom Worster) On 8/8/16 5:36 PM, Leigh wrote: > Hi all, > > There has been an unforeseen break with rand() when the minimum value is > greater than the maximum. > > Prior to 7.1 rand() would happily accept backwards parameters and return a > value, however in the 7.1 branch it now emits a warning and returns false. > > I've preemptively committed a fix to allow min > max and return a value as > in previous versions, but have kept the warning. > > Looking for some feedback/opinions on whether anyone else thinks this > should be fixed differently (or not at all). > > N.B. this also changes the behaviour of mt_rand to now accept min > max Your fix seems fine for rand() but less so for mt_rand(). Applying this fix will break much less mt_rand()-using code than not applying it will break rand()-using code. From that point of view, applying it is the better choice. Otoh, it's like copy-pasting a weird old bug from rand() to mt_rand(). The plan was to make rand() alias mt_rand(). Now I'm not sure that's a smart plan. Tom