Closed p5pRT closed 21 years ago
perl seg faults when I give it the following script. It looks like a bug\, doesn't it?
Etienne
====================================================================== #!/usr/bin/perl -w
## ## Make a package with an overloaded 'stringify' operator\, and see if ## I still can see the original reference type (HASH\, ARRAY ...) ##
$! = 1 ;
package Foo ; use overload '""' => sub {"ARRAY=moo-ha!ha!ha!"} ;
package main ;
$a = {} ; ## Here can tell if it's a hash\, array or whatever print "a=$a\, "\,ref($a)\,"\n\n" ;
$b = bless $a\,"Foo" ;
## Here can't anymore (btw\, $a has been blessed too) print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;
etienne@anonimo: perl stringify.pl a=HASH(0x80cc304)\, HASH
b=ARRAY=moo-ha!ha!ha!\, Foo a=ARRAY=moo-ha!ha!ha!\, Foo
etienne@isr: uname -a ; perl -v ; perl stringify.pl OSF1 isr.isr.ist.utl.pt V4.0 1229 alpha
This is perl\, version 5.003_21
Copyright 1987-1997\, Larry Wall
+ suidperl security patch Perl may be copied only under the terms of either the Artistic License or the GNU General Public License\, which may be found in the Perl 5.0 source kit.
a=HASH(0x140019868)\, HASH
b=ARRAY=moo-ha!ha!ha!\, Foo a=ARRAY=moo-ha!ha!ha!\, Foo
On Wed\, 22 Mar 2000 17:52:13 GMT\, etienne grossmann wrote:
#!/usr/bin/perl -w
## ## Make a package with an overloaded 'stringify' operator\, and see if ## I still can see the original reference type (HASH\, ARRAY ...) ##
$! = 1 ;
package Foo ; use overload '""' => sub {"ARRAY=moo-ha!ha!ha!"} ;
package main ;
$a = {} ; ## Here can tell if it's a hash\, array or whatever print "a=$a\, "\,ref($a)\,"\n\n" ;
$b = bless $a\,"Foo" ;
## Here can't anymore (btw\, $a has been blessed too) print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;
## Now\, I can again $c = bless $b\, "main" ; print "c=$c\, "\,ref($c)\,"\n" ; print "b=$b\, "\,ref($b)\,"\n" ; print "a=$a\, "\,ref($a)\,"\n\n" ;
FWIW\, this prints the following with 5.6.0-tobe:
Operation `.': no method found\, left argument has no overloaded magic\, right argument in overloaded package main at - line 22.
Sarathy gsar@ActiveState.com
Cannot duplicate bug on linux 2.2.16\, appears to be a bug in that version of linux.
Migrated from rt.perl.org#2577 (status was 'resolved')
Searchable as RT2577$