diff --git a/sv.c b/sv.c index 0382e961e728..e3026f7d3312 100644 --- a/sv.c +++ b/sv.c @@ -4834,8 +4834,8 @@ Perl_sv_set_undef(pTHX_ SV *sv) if (isGV_with_GP(sv)) Perl_ck_warner(aTHX_ packWARN(WARN_MISC), "Undefined value assigned to typeglob"); - - SvOK_off(sv); + else + SvOK_off(sv); } diff --git a/t/lib/warnings/sv b/t/lib/warnings/sv index ee0fdc25792b..64f624c5edb6 100644 --- a/t/lib/warnings/sv +++ b/t/lib/warnings/sv @@ -341,10 +341,13 @@ Invalid conversion in sprintf: "%+2L\003" at - line 19. # sv.c use warnings 'misc' ; *a = undef ; +(*c) = (); no warnings 'misc' ; *b = undef ; +(*d) = (); EXPECT Undefined value assigned to typeglob at - line 3. +Undefined value assigned to typeglob at - line 4. ######## # sv.c use warnings 'numeric' ;