On Tue Nov 14 19:02:09 2000, anno4000@lublin.zrz.tu-berlin.de wrote: > > This is a bug report for perl from anno4000@lublin.zrz.tu-berlin.de, > generated with the help of perlbug 1.28 running under perl v5.6.0. > > > ----------------------------------------------------------------- > [Please enter your report here] > > The code below demonstrates that under certain circumstances an object > (a hashref) can turn up n destruction with components missing > (undefined) > that were defined before. This happens when a reference to the object > is > stored in a package variable. > > In the code example, the object that turns up damaged during > destruction > is of class Obj in variable $obj. The (only) component of $obj is > $obj->{ gen}, which is defined throughout the existence of $obj, > but is found undef during destruction. > > > #!/usr/bin/perl > use strict; use warnings; $| = 1; > > package Gen; > > sub new { > bless {}, shift; > } > > sub obj { > my $self = shift; > _new Obj $self; # remember who created you > } > > package Obj; > > sub _new { > my $class = shift; > my $gen = shift; > die "Gah!\n" unless defined $gen; # never let an undef gen pass > bless { gen => $gen}, $class; > } > > sub DESTROY { > my $self = shift; > print "destroying $self\n"; > # $self->{ gen} should never be undef at this point > print "gen undef in destruction\n" unless defined $self->{ gen}; > } > > package main; > > my $gen = new Gen; > > our $obj = $gen->obj; # changing our to my makes the error go away > > print "generator defined\n" if defined $obj->{ gen}; # peeking in > # no warnings; # activating this makes the error go away > $obj; # commenting this out makes the error go away > > > > [Please do not change anything below this line] > ----------------------------------------------------------------- Pay attention to the line: 'gen undef in destruction' perl-5.6.0 rt-4700.pl Useless use of a variable in void context at rt-4700.pl line 39. generator defined destroying Obj=HASH(0x80ff948) gen undef in destruction perl-5.8.0 rt-4700.pl .. perl-5.8.8 rt-4700.pl Useless use of a variable in void context at rt-4700.pl line 39. generator defined destroying Obj=HASH(0x81484a0) perl-5.8.x rt-4700.pl (MAINT33934) Useless use of a variable in void context at rt-4700.pl line 39. generator defined destroying Obj=HASH(0x8124858) gen undef in destruction perl-5.10.0 rt-4700.pl (MAINT33934) Useless use of a variable in void context at rt-4700.pl line 39. generator defined destroying Obj=HASH(0x8169868) gen undef in destruction perl-blead rt-4700.pl Useless use of a variable in void context at rt-4700.pl line 39. generator defined destroying Obj=HASH(0x81707e8) gen undef in destruction Was the bug gone between 5.8.0 and 5.8.8 or was it just hiding? Kind regards, BramThread Previous | Thread Next