----- Original Message -----
From: "Michael Wallner"
Sent: Tuesday, November 07, 2006
> Matt Wilmas wrote:
> > Hi (Dmitry?),
> >
> > See Bug #33282 -- I saw it in the Bug Summary; don't know if there are
other
> > related ones... Same applies to foreach ($arr ... &$v) which is where I
> > noticed it last week with var_dump($arr). All elements that WERE
referenced
> > but aren't anymore still have is_ref=1 (when refcount=1). Only the last
> > referenced element should be a reference (unless the others were to
begin
> > with). unset()'ing the reference variable removes the reference from
the
> > last element. Example:
> >
> > $a = array(1, 2, 3);
> > $r = &$a[0];
> > $r = &$a[1];
> > $r = &$a[2];
> > var_dump($a);
> >
> > array(3) {
> > [0]=>
> > &int(1)
> > [1]=>
> > &int(2)
> > [2]=>
> > &int(3) // unset($r) will take care of this one
> > }
> >
> > The reference (&) should no longer be on the first 2 elements, right?
> > Setting is_ref=0 when refcount=1 in zend_assign_to_variable_reference()
> > fixes it. I assume it won't cause other problems since the same thing
is
> > done in zval_ptr_dtor(). :-)
> >
>
> This looks like it may actually fix a lot of previously bogus'ed bug
reports?
Not sure which ones you mean (searching for "reference" returns many bugs,
and I didn't look very thoroughly), but so everyone knows since I mentioned
foreach(), this doesn't change the behavior reported in Bugs #36240, #37410,
#39307, etc...
> --
> Michael
Matt
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php