diff --git a/mg.c b/mg.c index 08c8e23ebd32..0f22513098fe 100644 --- a/mg.c +++ b/mg.c @@ -3152,9 +3152,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) case '\027': /* ^W & $^WARNING_BITS */ if (*(mg->mg_ptr+1) == '\0') { if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { - i = SvIV(sv); PL_dowarn = (PL_dowarn & ~G_WARN_ON) - | (i ? G_WARN_ON : G_WARN_OFF) ; + | (SvTRUE_NN(sv) ? G_WARN_ON : G_WARN_OFF) ; } } else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) { diff --git a/t/lib/warnings/mg b/t/lib/warnings/mg index de7c98ad30df..d438d20211ac 100644 --- a/t/lib/warnings/mg +++ b/t/lib/warnings/mg @@ -169,3 +169,8 @@ EXPECT Use of uninitialized value $s in hash element at - line 13. Use of uninitialized value $_[0] in defined operator at - line 10. defined +######## +# NAME undefined $^W shouldn't warn +use warnings; +undef $^W +EXPECT diff --git a/t/op/reset.t b/t/op/reset.t index e4dcfc77f35b..a85e7ff4dbff 100644 --- a/t/op/reset.t +++ b/t/op/reset.t @@ -197,7 +197,7 @@ SKIP: my $warn = ''; local $SIG{__WARN__} = sub { $warn .= "@_\n" }; reset "\cW"; - like($warn, qr/uninitialized/, "magic tries to SvIV() the new value"); + is($warn, "", 'no warnings resetting $^W'); $warn = ''; is($^W, 0, q"check $^W has been zeroed"); is($warn, '', "should be no more warnings");