develooper Front page | perl.perl5.porters | Postings from November 2005

Re: [perl #37731] junk and uninit'ed values in tied scalars

Thread Previous | Thread Next
From:
Yitzchak Scott-Thoennes
Date:
November 23, 2005 19:17
Subject:
Re: [perl #37731] junk and uninit'ed values in tied scalars
Message ID:
20051124031730.GA3592@efn.org
On Tue, Nov 22, 2005 at 05:09:36PM -0800, lallip @ cs. rpi. edu wrote:
>     Here is a short program that illustrates bug #1:
> 
>         sub foo::TIESCALAR { bless {value => $_[1]}, $_[0] }
>         sub foo::FETCH { $_[0]->{value} }
>         tie my $test, 'foo', 'test';
>         print "$test$test\n";
> 
> This prints "testp\cX\c@" or other similar garbage. The first
> interpolation prints fine; the second is reminiscent of a
> non-NUL-terminated C string.

Hmm, does Robin's #26192 fix this, too?

>     Here is a short program that illustrates bug #2:
> 
>         use warnings;
>         sub foo::TIESCALAR { bless {}, shift }
>         sub foo::FETCH { return 2 }
>         tie my $test, 'foo';
>         my $bits = 3 & ~$test;
> 
> This gives the warning
>         Use of uninitialized value in 1's complement (~) at....

Fixed in blead, probably by #22163, which Nicholas has hesitated to
add to maint.
 
>     Finally, the mysterious Bug #3:
> 
>         sub foo::TIESCALAR { bless {value => $_[1]}, $_[0] }
>         sub foo::FETCH { $_[0]->{value} }
>         tie my $VAR, 'foo', 'SEARCH';
>         foreach my $var ($VAR)
>         {
>            print +($var eq $VAR) ? 'yes' : 'no';
>         }
> 
> This prints "no".

Still a problem in blead.  I hope any fix to this would make something
that does: sub FETCH { ++$_[0]->{value} } have eq return *false*.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About