From: Adrian M. Enache Date: Sun, 3 Aug 2003 18:00:05 +0000 (+0300) Subject: Re: [perl #23207] persistant sideffect involving bitwise xor and substr X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6214ab63745c28e26e752f88d98bf89671cabc77;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #23207] persistant sideffect involving bitwise xor and substr Message-ID: <20030803150005.GA1319@ratsnest.hole> p4raw-id: //depot/perl@20462 --- diff --git a/pp.c b/pp.c index 8a7632a..2958fba 100644 --- a/pp.c +++ b/pp.c @@ -3111,6 +3111,8 @@ PP(pp_substr) sv_upgrade(TARG, SVt_PVLV); sv_magic(TARG, Nullsv, PERL_MAGIC_substr, Nullch, 0); } + else + (void)SvOK_off(TARG); LvTYPE(TARG) = 'x'; if (LvTARG(TARG) != sv) { diff --git a/t/op/substr.t b/t/op/substr.t index 17f86e3..533f1a5 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -1,6 +1,6 @@ #!./perl -print "1..175\n"; +print "1..176\n"; #P = start of string Q = start of substr R = end of substr S = end of string @@ -592,3 +592,13 @@ ok 174, $x eq "\x{100}\x{200}\xFFb"; $r[$_] = \ substr $s, $_, 1 for (0, 1); ok 175, join("", map { $$_ } @r) eq "ab"; } + +# [perl #23207] +{ + sub ss { + substr($_[0],0,1) ^= substr($_[0],1,1) ^= + substr($_[0],0,1) ^= substr($_[0],1,1); + } + my $x = my $y = 'AB'; ss $x; ss $y; + ok 176, $x eq $y; +}