diff options
-rw-r--r-- | doop.c | 1 | ||||
-rw-r--r-- | t/op/tr.t | 10 |
2 files changed, 9 insertions, 2 deletions
@@ -632,7 +632,6 @@ Perl_do_trans(pTHX_ SV *sv) PERL_ARGS_ASSERT_DO_TRANS; if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL)) { - if (!SvIsCOW(sv)) Perl_croak_no_modify(); } (void)SvPV_const(sv, len); @@ -8,7 +8,7 @@ BEGIN { require './test.pl'; } -plan tests => 132; +plan tests => 134; my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1); @@ -526,4 +526,12 @@ SKIP: { is($x, "PerlĪ²", "Only first of multiple transliterations is used"); } +# tr/a/b/ should fail even on zero-length read-only strings +use constant nullrocow => (keys%{{""=>undef}})[0]; +for ("", nullrocow) { + eval { $_ =~ y/a/b/ }; + like $@, qr/^Modification of a read-only value attempted at /, + 'tr/a/b/ fails on zero-length ro string'; +} + 1; |