On 31/03/2016 18:23, Rowan Collins wrote:
Maybe in PHP 5 the opcodes are the same, but $2 and $3 somehow end up as references to !0, rather than new zvals

So, it turns out, this is exactly what happens. Specifically, there is a call to SEPARATE_ZVAL_IF_NOT_REF(var_ptr); in the definition of the ZEND_PRE_INC opcode [http://lxr.php.net/xref/PHP_5_6/Zend/zend_vm_def.h#814] If the zval *is* a reference, the code just ends up incrementing its reference count, returning a reference to it rather than the calculated value.

In PHP 7, references are very different, and integers aren't refcounted, so it's all a different story.

I got a bit curious and did some deep investigation, which I've written up on StackOverflow: http://stackoverflow.com/a/36344524/157957 I've about reached my limit now, though, so I'll leave it to others to correct or fill in any further info. :)

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to