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
Reference to constant not read-only #1801
Comments
From eblood@xmission.comCreated by eblood@xmission.comWhen useithreads is defined the following code does not produce sub C () { 1 } The problem is that constants are put on the pad when useithreads The following patch corrects this and adds a test case for it. Inline Patchdiff -bruN perl.sav/pp.c perl/pp.c
--- perl.sav/pp.c Fri Mar 24 22:24:52 2000
+++ perl/pp.c Fri Apr 07 08:05:42 2000
@@ -510,6 +510,13 @@
SvTEMP_off(sv);
(void)SvREFCNT_inc(sv);
}
+#ifdef USE_ITHREADS
+ else if (SvPADTMP(sv) && SvREADONLY(sv)) {
+ /* Must be a const */
+ sv = newSVsv(sv);
+ SvREADONLY_on(sv);
+ }
+#endif
else if (SvPADTMP(sv))
sv = newSVsv(sv);
else {
diff -bruN perl.sav/t/op/ref.t perl/t/op/ref.t
--- perl.sav/t/op/ref.t Fri Mar 24 22:23:58 2000
+++ perl/t/op/ref.t Fri Apr 07 19:34:38 2000
@@ -1,6 +1,6 @@
#!./perl
-print "1..56\n";
+print "1..57\n";
# Test glob operations.
@@ -279,17 +279,33 @@
print ${\$_} for @a;
}
+# test if ref to constant is readonly
+
+{
+ eval {
+ sub C () { 1 }
+ my $r = \C;
+ print "# should also generate an error...\n";
+ $$r = 2;
+ };
+ if ($@) {
+ print "# $@";
+ print "ok 54\n" if $@ =~ /^Modification of a read-only/;
+ }
+}
+
# test global destruction
package FINALE;
{
- $ref3 = bless ["ok 56\n"]; # package destruction
- my $ref2 = bless ["ok 55\n"]; # lexical destruction
- local $ref1 = bless ["ok 54\n"]; # dynamic destruction
+ $ref3 = bless ["ok 57\n"]; # package destruction
+ my $ref2 = bless ["ok 56\n"]; # lexical destruction
+ local $ref1 = bless ["ok 55\n"]; # dynamic destruction
1; # flush any temp values on stack
}
DESTROY {
print $_[0][0];
}
+ Perl Info
|
Migrated from rt.perl.org#3060 (status was 'resolved')
Searchable as RT3060$
The text was updated successfully, but these errors were encountered: