All support for the Borland compiler has been dropped. The code had not
worked for a long time anyway.
+=head2 Weakening read-only references
+
+Weakening read-only references is no longer permitted. It should never
+hove worked anyway, and in some cases could result in crashes.
+
=head1 Deprecations
XXX Any deprecated features, syntax, modules etc. should be listed here.
shared memory, causing the existing cached numeric representation in the
scalar to persist [perl #98480].
+=item *
+
+Weakening the first argument to an automatically-invoked C<DESTROY> method
+could result in erroneous "DESTROY created new reference" errors or
+crashes. Now it is an error to weaken a read-only reference.
+
=back
=head1 Known Problems
Perl_ck_warner(aTHX_ packWARN(WARN_MISC), "Reference is already weak");
return sv;
}
+ else if (SvREADONLY(sv)) croak_no_modify();
tsv = SvRV(sv);
Perl_sv_add_backref(aTHX_ tsv, sv);
SvWEAKREF_on(sv);
use strict qw(refs subs);
-plan(221);
+plan(222);
# Test glob operations.
}
+SKIP:{
+ skip_if_miniperl "no Scalar::Util on miniperl", 1;
+ my $error;
+ *hassgropper::DESTROY = sub {
+ require Scalar::Util;
+ eval { Scalar::Util::weaken($_[0]) };
+ $error = $@;
+ # This line caused a crash before weaken refused to weaken a
+ # read-only reference:
+ $do::not::overwrite::this = $_[0];
+ };
+ my $xs = bless [], "hassgropper";
+ undef $xs;
+ like $error, qr/^Modification of a read-only/,
+ 'weaken refuses to weaken a read-only ref';
+ # Now that the test has passed, avoid sabotaging global destruction:
+ undef *hassgropper::DESTROY;
+ undef $do::not::overwrite::this;
+}
+
+
# Bit of a hack to make test.pl happy. There are 3 more tests after it leaves.
$test = curr_test();
curr_test($test + 3);