Hi all,
Current Zend hash uses ulong for numeric array indexes.
This causes bug #67693
https://bugs.php.net/bug.php?id=67693
Signed/unsigned mismatch is the root cause of this bug.
Since PHP's int is signed by default, it might be better
to change Zend hash index to signed long.
I would like to hear comments who understand Zend internals. If there aren't
issues, we may have signed long index for PHP7.
I also would like to hear comments for possible fix in released versions.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Current Zend hash uses ulong for numeric array indexes.
This causes bug #67693https://bugs.php.net/bug.php?id=67693
Signed/unsigned mismatch is the root cause of this bug.
Since PHP's int is signed by default, it might be better
to change Zend hash index to signed long.I would like to hear comments who understand Zend internals. If there aren't
issues, we may have signed long index for PHP7.
I noticed this myself (and am currently figuring out how to deal with it) while implementing bigints in phpng (see my draft RFC for that). Converting from long to ulong and letting the sign just change is madness, I’d fully support a move to signed longs. This would at least mean that integer casting is the same as index casting, at least for floats (the fact we handle [“9999999999999999999999999999999”] differently to [9999999999999999999999999999999] is a different kettle of fish, but perhaps also worth discussing). Principle of least astonishment applies, I think.
I think it was agreed with the 64-bit/phpng compromise that array indices should be 32-bit, but I wonder also if having them be 64-bit might not be bad, to allow sparse arrays for example.
Note that my bigints RFC and patch don’t use bigint indices. While probably possible, I really, really don’t want to try and implement that.
--
Andrea Faulds
http://ajf.me/
Hi,
Hi all,
Current Zend hash uses ulong for numeric array indexes.
This causes bug #67693https://bugs.php.net/bug.php?id=67693
Signed/unsigned mismatch is the root cause of this bug.
Since PHP's int is signed by default, it might be better
to change Zend hash index to signed long.
Instead of doing that, why not simply disallow negative array indices to be
used as integers?
In other words, negative indices are treated as if you had used strings so
that it doesn't upset the the last numeric index kept in the array
structure.
From what I can tell, it should be a pretty simply patch.
Thoughts?
I would like to hear comments who understand Zend internals. If there
aren't
issues, we may have signed long index for PHP7.I also would like to hear comments for possible fix in released versions.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
--
Tjerk