develooper Front page | perl.perl5.porters | Postings from July 2003

Re: [perl #22977] Bug in format/write

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
July 14, 2003 15:14
Subject:
Re: [perl #22977] Bug in format/write
Message ID:
20030714221528.GA20824@fdgroup.com
On Mon, Jul 14, 2003 at 05:37:42AM -0000, Ruediger Schopper wrote:
> I belive, that we've found a bug in perl. We discovered it when changing from
> perl-5.4.4 to perl-5.8.0, where we got strange results with
> write in a program we heavily used without problems.

The bug can be reduced to the simpler case:

    sub f ($); # Comment out to get right result!
    sub f ($) {
	my $test = $_[0];
	write;
	format STDOUT =
    @<<<<<<<
    $test
    .
    }
    f(1);
    f(2);

It's due to there being multiple CVs associated with f due to to the
forward declaration, and to newATTRSUB() copying the contents of the
second CV to the first.  This causes any nested subs to have CvOUTSIDE
pointing to the wrong CV. A call to pad_fixup_inner_anons() fixes up any
nested anon subs, but nested formats aren't fixed up.

Since I'm currently working on trying to get sub declarations
to take effect at the start of a sub rather than at the end (eg
sub f($) { f(1) }), I'll see if I can work in a fix for this at the
same time.

-- 
"You're so sadly neglected, and often ignored.
A poor second to Belgium, When going abroad."
Monty Python - "Finland"

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