-
Notifications
You must be signed in to change notification settings - Fork 578
@_ gets corrupted when F(@X) shortens @X #4924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From [email protected]Created by [email protected](Also reproduced in 5.005) SAMPLE CODE: Here is a sample program: sub F { With the curious output: start,A,B,C,D,E,end BUG: The bug is that in F, after @X is emptied, @_ seems to contain dangling EXPECTED BEHAVIOR: How is this supposed to work? What should @_ reference if @X BIGGER EXAMPLE: In the following, @_ ends up referencing something that causes a #!/usr/local/bin/perl5.6.1 -w local @X; sub Main { @X = (); print 'clear: ', join(',', @_), "\n"; # @_ seems ok, but isn't my @z = qw/ MAGIC STRINGS /; print 'magic: ', join(',', @_), "\n"; # oops, dangling pointer??? require Carp; # massage heap print 'trash: ', join(',', @_), "\n"; # oops, more trash from load my @a = @_; # crash (maybe?) : Bizarre copy of CODE in aassign at ./test2 line 9. @X = qw/ A B C D E F G H I J K L M /; Perl Info
|
From @schwernConfirmed from bleadperl back to 5.003_07 at least. On Mon, Jan 28, 2002 at 01:30:13PM -0500, Justin Vallon wrote:
The local doesn't appear to be necessary for the bug to manifest.
-- Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/ |
From [Unknown Contact. See original ticket]On Jan 28, Michael G Schwern said:
I'm not sure this is a bug. The elements of @_ are aliases to the elements passed to the function. ($x, $y, $z) = (1,2,3); sub foo { @_ is its separate array, it holds its own elements, albeit aliases to $x = "japhy"; sub prechop { substr($_[0], 0, 1, '') } This seems consistent. -- |
From @ysth
True 'nuf. But look again and explain why changing @Y affects @_.
|
From [Unknown Contact. See original ticket]On Jan 28, Yitzchak Scott-Thoennes said:
Well, it doesn't appear to futz up in bleadperl... -- |
From @schwernOn Mon, Jan 28, 2002 at 10:18:43PM -0500, Jeff 'japhy' Pinyan wrote:
It does @14190. -- Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/ |
From @iabyn
Yes it's a bug, and no, it can't easily be fixed. It's all because stuff The individual SVs that make up the elements of @X start off with a refcnt Fixed in Perl 6? :-( |
From [Unknown Contact. See original ticket]However, in my sample code, @_ is corrupt, not modified. If you pass an It appears that the aliasing of the elements that occurs when @_ is created -Justin -----Original Message----- On Jan 28, Michael G Schwern said:
I'm not sure this is a bug. The elements of @_ are aliases to the elements passed to the function. ($x, $y, $z) = (1,2,3); sub foo { @_ is its separate array, it holds its own elements, albeit aliases to $x = "japhy"; sub prechop { substr($_[0], 0, 1, '') } This seems consistent. -- *********************************************************************** |
Migrated from rt.perl.org#8358 (status was 'open')
Searchable as RT8358$
The text was updated successfully, but these errors were encountered: