The logic exempting copy-on-write scalars from read-only checks in
sv_bless was left over from when READONLY+FAKE meant copy-on-write.
Perl_croak(aTHX_ "Can't bless non-reference value");
tmpRef = SvRV(sv);
if (SvFLAGS(tmpRef) & (SVs_OBJECT|SVf_READONLY)) {
- if (SvREADONLY(tmpRef) && !SvIsCOW(tmpRef))
+ if (SvREADONLY(tmpRef))
Perl_croak_no_modify();
if (SvOBJECT(tmpRef)) {
SvREFCNT_dec(SvSTASH(tmpRef));
require './test.pl';
}
-plan (110);
+plan (111);
sub expected {
my($object, $package, $type) = @_;
eval { _117941() };
like $@, qr/^Attempt to bless into a freed package at /,
'bless with one arg when current stash is freed';
+
+for(__PACKAGE__) {
+ eval { bless \$_ };
+ like $@, qr/^Modification of a read-only value attempted/,
+ 'read-only COWs cannot be blessed';
+}