Bug #65239 [Asn->Csd]: Strings of 2GB
| From: | krakjoe@php.net | Date: | Fri, 08 Nov 2013 08:07:08 +0000 |
| Subject: | Bug #65239 [Asn->Csd]: Strings of 2GB | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10590@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65239&edit=1
ID: 65239
Updated by: krakjoe@php.net
Reported by: pacerier at gmail dot com
Summary: Strings of 2GB
-Status: Assigned
+Status: Closed
Type: Bug
Package: Documentation problem
Operating System: linux
PHP Version: 5.3.26
Assigned To: mumumu
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2013-11-08 08:06:51] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&revision=332084
Log: #65239 precise maximum
------------------------------------------------------------------------
[2013-07-10 17:47:09] pacerier at gmail dot com
Description:
------------
The documentation at http://php.net/manual/en/language.types.string.php
states
that "string can be as large as 2GB".
Now 2GB means 2*1024^3 = 2147483648 bytes.
The documentation is misleading, because strings start to misbehave once they get
as large as 2147483647 bytes, and not 2147483648 bytes.
Yes I know, it's just a 1 byte difference, but it makes a difference between code
that works and code that breaks.
Test script:
---------------
error_reporting(E_STRICT|E_ALL);
ini_set('memory_limit', '-1');
$gb = 1024 * 1024 * 1024;
$str = str_repeat('a', 2 * $gb);
echo $str[0]; // Notice: Uninitialized string offset: 0
Expected result:
----------------
The test script should output the string "a", since
http://php.net/manual/en/language.types.string.php
specifically claims that
strings can be as large as 2147483648 bytes.
Alternatively, we should re-word the documentation: Strings can be as large as
2147483647 bytes. Failure to adhere to do so would result in undefined behavior
(for example, strlen etc).
Actual result:
--------------
Notice: Uninitialized string offset: 0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65239&edit=1