[comp.lang.perl] Perl 3.0 pl41 on a Stardent GS2000

scp@acl.lanl.gov (Stephen C. Pope) (01/11/91)

For those interested:

I got pl41 up and running on a GS2000 running os 2.2.  Passes all tests
if compiled without optimization; with optimization, it fails bad
on lib.big.  Problem has something to do with arrays: I fixed up
bigint.pl with some print statements (see below), to demonstrate
the problem.

Using the perl compiled with -O, running this simple program:

#! ./perl
do './bigint.pl';
print &badd('1','0') . "\n";


produced this output:

% ./tt
start add loop $x = 1 $#x = 0 @x = 1
end add loop $x = 1 $#x = 0 @x = 1
after add loop $#x = -1 @x =
+0
%

Of course, The one element in @x shouldn't have been lost!

One would assume the compiler was at fault...

Here's the bigint.pl code I modified:

sub add { #(int_num_array, int_num_array) return int_num_array
    local(*x, *y) = @_;
    $car = 0;
    for $x (@x) {
print "start add loop \$x = $x \$\#x = $#x \@x = @x\n";
        last unless @y || $car;
        $x -= 100000 if $car = (($x += shift @y + $car) >= 100000);
print "end add loop \$x = $x \$\#x = $#x \@x = @x\n";
    }
print "after add loop \$\#x = $#x \@x = @x\n";
    for $y (@y) {
        last unless $car;
        $y -= 100000 if $car = (($y += $car) >= 100000);
    }
    (@x, @y, $car);
}



stephen pope
advanced computing lab, lanl
scp@acl.lanl.gov