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
Assigning value of an op on an SV to said SV somtimes fails #458
Comments
From cloos@adamsmith.aiThis works in 5.005_03, but fails in certain complex scripts in 5.005_6[01]: after code of the form: my $f = "foo"; $f usually -- and always in this simple example -- holds "3,foo". Presumably, sometimes $l and the first delimiter get assigned to $f before The script where this shows up does use IO::File, IO::Socket and POSIX, if So, is it a bug in 5.005_6[01] or is just a assignment undefined behavior? Perl Info
|
From [Unknown Contact. See original ticket]James H. Cloos Jr. writes:
This is my "optimize the assignment away" patch. I will think about Ilya |
From [Unknown Contact. See original ticket]James H . Cloos Jr . <cloos@adamsmith.ai> writes:
It is a bug. But as you say it does not occur with simple examples. -- |
From [Unknown Contact. See original ticket]Ilya Zakharevich writes:
Enjoy the patch (tested with _58), Inline Patch--- ./op.c~ Wed Aug 11 00:52:10 1999
+++ ./op.c Tue Aug 31 21:35:30 1999
@@ -5161,6 +5161,19 @@ Perl_ck_sassign(pTHX_ OP *o)
{
return o;
}
+ if (kid->op_type == OP_JOIN) {
+ /* do_join has problems if the arguments coincide with target.
+ In fact the second argument *can* safely coincide with it,
+ but we ignore=pessimize this rare occasion. */
+ OP *arg = kLISTOP->op_first->op_sibling; /* Skip PUSHMARK */
+
+ while (arg) {
+ if (arg->op_type == OP_PADSV
+ && arg->op_targ == kkid->op_targ)
+ return o;
+ arg = arg->op_sibling;
+ }
+ }
kid->op_targ = kkid->op_targ;
/* Now we do not need PADSV and SASSIGN. */
kid->op_sibling = o->op_sibling; /* NULL */ |
From [Unknown Contact. See original ticket]Ilya Zakharevich writes:
Oups, forgot to include the test patch. Ignore the previous patch, Inline Patch--- ./t/op/join.t~ Tue Jul 20 10:18:14 1999
+++ ./t/op/join.t Tue Aug 31 21:40:50 1999
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: join.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:01 $
-
-print "1..3\n";
+print "1..6\n";
@x = (1, 2, 3);
if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";}
@@ -10,3 +8,15 @@ if (join(':',@x) eq '1:2:3') {print "ok
if (join('',1,2,3) eq '123') {print "ok 2\n";} else {print "not ok 2\n";}
if (join(':',split(/ /,"1 2 3")) eq '1:2:3') {print "ok 3\n";} else {print "not ok 3\n";}
+
+my $f = 'a';
+$f = join ',', 'b', $f, 'e';
+if ($f eq 'b,a,e') {print "ok 4\n";} else {print "# '$f'\nnot ok 4\n";}
+
+$f = 'a';
+$f = join ',', $f, 'b', 'e';
+if ($f eq 'a,b,e') {print "ok 5\n";} else {print "not ok 5\n";}
+
+$f = 'a';
+$f = join $f, 'b', 'e', 'k';
+if ($f eq 'baeak') {print "ok 6\n";} else {print "# '$f'\nnot ok 6\n";}
--- ./op.c~ Wed Aug 11 00:52:10 1999
+++ ./op.c Tue Aug 31 21:35:30 1999
@@ -5161,6 +5161,19 @@ Perl_ck_sassign(pTHX_ OP *o)
{
return o;
}
+ if (kid->op_type == OP_JOIN) {
+ /* do_join has problems the arguments coincide with target.
+ In fact the second argument *can* safely coincide,
+ but ignore=pessimize this rare occasion. */
+ OP *arg = kLISTOP->op_first->op_sibling; /* Skip PUSHMARK */
+
+ while (arg) {
+ if (arg->op_type == OP_PADSV
+ && arg->op_targ == kkid->op_targ)
+ return o;
+ arg = arg->op_sibling;
+ }
+ }
kid->op_targ = kkid->op_targ;
/* Now we do not need PADSV and SASSIGN. */
kid->op_sibling = o->op_sibling; /* NULL */ |
Migrated from rt.perl.org#1299 (status was 'resolved')
Searchable as RT1299$
The text was updated successfully, but these errors were encountered: