diff --git a/pp_hot.c b/pp_hot.c index 3d46287c7a08..06b837bf1575 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -501,10 +501,13 @@ PP(pp_add) svl = TOPm1s; useleft = USE_LEFT(svl); - if(useleft && svr == svl) { + if(useleft && svr == svl && SvGMAGICAL(svl)) { /* Print the uninitialized warning now, so it includes the vari- able name. */ - if (!SvOK(svl)) report_uninit(svl), useleft = 0; + if (!SvOK(svl)) { + if (ckWARN(WARN_UNINITIALIZED)) report_uninit(svl); + useleft = 0; + } /* Non-magical sv_mortalcopy */ svl = sv_newmortal(); sv_setsv_flags(svl, svr, 0); diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 33cc2b90804f..1dcee790e25b 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -694,6 +694,8 @@ sub FETCH { undef } tie my $m1, ""; my $v = $m1 + $m1; +no warnings; +$v = $m1 + $m1; EXPECT Use of uninitialized value $m1 in addition (+) at - line 6. Use of uninitialized value $m1 in addition (+) at - line 6.