Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71070 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11075 invoked from network); 11 Jan 2014 18:31:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2014 18:31:36 -0000 Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.48 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.128.48 mail-qe0-f48.google.com Received: from [209.85.128.48] ([209.85.128.48:46337] helo=mail-qe0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/30-07897-70E81D25 for ; Sat, 11 Jan 2014 13:31:36 -0500 Received: by mail-qe0-f48.google.com with SMTP id k5so4409426qej.21 for ; Sat, 11 Jan 2014 10:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=tXuVs4I9wlr71wm4oCl21BoFYs0msqtvaeHNVBotJa8=; b=sEjh2V1l/hGqc6dn7N1YvFpOpH1Q+MWVvGaa9QBqCha1okqS5K8U6VfRipzd7q0OtD a4LYyqMvg4DEY6OaKnyT5a124Ho828rIjL32fds49btGoKTHYXCwOkBfGUdg6qdX/Q62 MpV+EPlckJYjQzkH0hIsPp7WmVn7Y1GT4mnoIOzuEnPwvAsCeaUTp7yiVfrHMIwBSGVI eQpH4yLqYqAXRQAWl4QcucWqEYyG3BD/WY/vxXJWPEBgef6r1TZHFypjslseZcyeLHBy 7XckYafcD0erZP4H52qxH6rso1FBWOEjcjv6z4mSvYPQhglTvCfKr44u53xkCoY9jPXK mg0g== MIME-Version: 1.0 X-Received: by 10.224.66.134 with SMTP id n6mr21426850qai.39.1389465093913; Sat, 11 Jan 2014 10:31:33 -0800 (PST) Sender: jakub.php@gmail.com Received: by 10.224.68.68 with HTTP; Sat, 11 Jan 2014 10:31:33 -0800 (PST) In-Reply-To: References: <10f19e40b03ee19837010a988eb05706.squirrel@webmail.klapt.com> <2e9df2840916d6e72255764a08086e57.squirrel@webmail.klapt.com> Date: Sat, 11 Jan 2014 18:31:33 +0000 X-Google-Sender-Auth: fWkR-vtPHwcoLZqsPrkPNYacxDw Message-ID: To: Anatol Belski Cc: Hannes Magnusson , Nikita Popov , PHP Developers Mailing List Content-Type: multipart/alternative; boundary=001a11c2bd8459c17b04efb60dbd Subject: Re: [PHP-DEV] [RFC] 64 bit platform improvements for string length and integer From: bukka@php.net (Jakub Zelenka) --001a11c2bd8459c17b04efb60dbd Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jan 11, 2014 at 4:53 PM, Anatol Belski wrote: > Hi Jakub, > > On Sat, January 11, 2014 17:08, Jakub Zelenka wrote: > > On Sat, Jan 11, 2014 at 3:29 PM, Anatol Belski wrote: > > > > > >> > >> yep, that's exactly how it performs till now in the mainstream, just > >> replace ZEND_INT_MAX with LONG_MAX. Adding a warning to every such case > >> would cause a warning flood in many PHP apps, guaranteed :) Whereby it > >> might be ok for debug mode maybe, I wouldn't do it as I can't remember > >> any WTFs about the behavior. > >> > >> > >> > > I meant adding warning only for overflow cases. Values in existing apps > > can't be bigger than LONG_MAX so I don't see how it could cause warning > > flood in the current PHP apps. I don't even think that users will be > > often using such a big values after the 64bit changes. > > > > The thing is that if I use value bigger than LONG_MAX after 64bit changes > > and I pass it to the function defined in extension that does not support > > it (use "l" in zpp), then I rather see warning than unexpected rounding > to > > LONG_MAX... There is no way how to find out (except looking to the ext > > sources) that the big values are not supported. If I get warning, I can > > fix it in the code straight away... > > > But isn't it the exact situation now on ILP32 vs LP64 systems? Like 32 vs > 64 bit Linux? I haven't suggested 'l' to handle the param the old way, > just it to be an alias for 'i'. In the new code that would be as dynamic > as php_int_t is, however 'l' as alias would retain zpp compatibility to > the older PHP. > > For instance how much sense had such a centralized warding for the snippet > is_int(PHP_INT_MAX+1) ? There is a lot of functions accepting an arbitrary > numeric value and not depending on any library, why they should throw a > warning by default? Why should we throw a warning about 32 bit in the 64 > bit build? Furtehrmore, LONG_MAX is 64 bit on LP64 systems, that would be > the same as PHP_INT_MAX. > > This is of course just about LLP64 when the situation has changed. I think that we are talking about slightly different things. Sorry my first example was a bit incorrect (ZEND_INT_MAX = _I64_MAX which is bigger than LONG_MAX on LLP64) What I was suggesting is keeping BC for code like this: ... long n; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &n) == FAILURE) { return; } ... The warning would be thrown if it's bigger than LONG_MAX or smaller than LONG_MIN. If I understood correctly you are suggesting using php_int_t for n (defined in compat header as long if not defined in php.h)? The problem is that the type would be dependent on PHP versions and when you need to be sure that it's a long (which might be the case when you pass it to the another lib function), then you need to check PHP_API_VERSION and in case it's not long, you have to do range check. In general, I think that would be better to keep BC for "l" and use it just for long values (the "l" actually stands for long... :) ). That could be achieved adding range checks with warning if the value is bigger than LONG_MAX or smaller than LONG_MIN in zend_parse_arg_impl (it would probably require small changes in zend_parse_arg [expected_value...]). Btw. I see your point about the arbitary number. But I also feel that it would be better to keep it as long as it would keep the same behavior when passed to external libs. Cheers Jakub --001a11c2bd8459c17b04efb60dbd--