From: Bram Date: Sat, 24 May 2008 12:34:22 +0000 (-0700) Subject: [perl #36875] [PATCH] scalar reverse undef does not warn (was: Certain string handl... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e21d011cd8eaa435798e00abe4c9c96270a5be5;p=p5sagit%2Fp5-mst-13.2.git [perl #36875] [PATCH] scalar reverse undef does not warn (was: Certain string handling functions don't warn on undef) From: "Bram via RT" Message-ID: p4raw-id: //depot/perl@33981 --- diff --git a/pp.c b/pp.c index d940d10..10dbb06 100644 --- a/pp.c +++ b/pp.c @@ -4604,13 +4604,18 @@ PP(pp_reverse) SvUTF8_off(TARG); /* decontaminate */ if (SP - MARK > 1) do_join(TARG, &PL_sv_no, MARK, SP); - else + else { sv_setsv(TARG, (SP > MARK) ? *SP : (padoff_du = find_rundefsvoffset(), (padoff_du == NOT_IN_PAD || PAD_COMPNAME_FLAGS_isOUR(padoff_du)) ? DEFSV : PAD_SVl(padoff_du))); + + if (! SvOK(TARG) && ckWARN(WARN_UNINITIALIZED)) + report_uninit(TARG); + } + up = SvPV_force(TARG, len); if (len > 1) { if (DO_UTF8(TARG)) { /* first reverse each character */ diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 0a984e2..16ce1b8 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -1400,3 +1400,14 @@ my $b EXPECT Use of uninitialized value $undef in addition (+) at - line 4. Use of uninitialized value $undef in addition (+) at - line 7. +######## +use warnings 'uninitialized'; +my ($r1, $r2); +$_ = undef; +$v = reverse; +$v = reverse $r1; +$v = reverse "abc", $r2, "def"; +EXPECT +Use of uninitialized value in reverse at - line 4. +Use of uninitialized value $r1 in reverse at - line 5. +Use of uninitialized value $r2 in reverse at - line 6.