develooper Front page | perl.perl5.porters | Postings from September 2010

[perl #39358] sort with custom subname and prototype ($$) segfaults intermittently

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 26, 2010 14:39
Subject:
[perl #39358] sort with custom subname and prototype ($$) segfaults intermittently
Message ID:
rt-3.6.HEAD-5116-1285537189-1198.39358-14-0@perl.org
On Thu Jun 08 21:23:40 2006, johnh@isi.edu wrote:
> #!/usr/bin/perl -w
> 
> @scores = (
>   '0000.0000.00039:0000.0008.0031.',
>   '0000.0000.00032:0000.0008.0024.',
>   '0002.0002.00033:0002.0011.0020.',
>   '0028.0028.00190:0077.0085.0028.');
> 
> @match_indices = (0,1,2,3);
> sub sort_by_index($$) {
>     my($A,$B) = @_;
>     return $scores[$match_indices[$A]] cmp
>    $scores[$match_indices[$B]];
> }
> @match_indices = sort sort_by_index @match_indices;
> ----------------------------------------

This gives me:
Bizarre copy of UNKNOWN in aelem at - line 12.
in commit 42bd538f820268331bc55a66fa9df0673de69250

d963bf01c4c4db296760b1148f98bf668efcaf58, three commits later (the
intervening commits affecting only documentation), gives 
Use of uninitialized value $match_indices[2] in array element at - line 12.
Use of uninitialized value $match_indices[2] in array element at - line 12.
Use of uninitialized value $match_indices[0] in array element at - line 12.

but I can’t see how it fixes it.


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