develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #21979] Modifying an alias to a read-only item of an argument list of a subroutine works, while it's expected to fail

Thread Previous
From:
Dmitry Karasik via RT
Date:
January 6, 2012 13:16
Subject:
[perl #21979] Modifying an alias to a read-only item of an argument list of a subroutine works, while it's expected to fail
Message ID:
rt-3.6.HEAD-14510-1325884313-1429.21979-15-0@perl.org
I'd like to reopen this old bug as I've hit it in my own code... I've no
idea how to fix it properly, but at least before that is decided either
way, I believe issuing a warning gives some idea that there's undefined
behavior:

--- pp.c.0    2012-01-06 01:07:34.511988700 +0100
+++ pp.c    2012-01-06 19:04:06.311428300 +0100
@@ -515,9 +515,11 @@
     SvTEMP_off(sv);
     SvREFCNT_inc_void_NN(sv);
     }
-    else if (SvPADTMP(sv) && !IS_PADGV(sv))
+    else if (SvPADTMP(sv) && !IS_PADGV(sv)) {
+        Perl_ck_warner(aTHX_ packWARN(WARN_MISC),
+         "Implicit copy of a read-only scalar due to aliasing");
         sv = newSVsv(sv);
-    else {
+    } else {
     SvTEMP_off(sv);
     SvREFCNT_inc_void_NN(sv);
     }




---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=21979

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About