if (!sv)
RETPUSHUNDEF;
- SV_CHECK_THINKFIRST_COW_DROP(sv);
+ if (SvTHINKFIRST(sv))
+ sv_force_normal_flags(sv, SV_COW_DROP_PV|SV_IMMEDIATE_UNREF);
switch (SvTYPE(sv)) {
case SVt_NULL:
use vars qw(@ary %ary %hash);
-plan 73;
+plan 74;
ok !defined($a);
}
is $_[0], $_[1], 'undef constants preserve identity';
+# [perl #122556]
+my $messages;
+package Thingie;
+DESTROY { $messages .= 'destroyed ' }
+package main;
+sub body {
+ sub {
+ my $t = bless [], 'Thingie';
+ undef $t;
+ }->(), $messages .= 'after ';
+
+ return;
+}
+body();
+is $messages, 'destroyed after ', 'undef $scalar frees refs immediately';
+
+
# this will segfault if it fails
sub PVBM () { 'foo' }