From: Marcus Holland-Moritz <mhx-perl@gmx.net>
Date: Thu, 6 May 2004 17:19:17 +0000 (+0000)
Subject: [perl #29346] Double warning for int(undef) and abs(undef)
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=922c43655b68a766f6d1b8a30cddd076db7b54d7;p=p5sagit%2Fp5-mst-13.2.git

[perl #29346] Double warning for int(undef) and abs(undef)
Remove the duplicate warnings and update tests.

p4raw-id: //depot/perl@22796
---

diff --git a/pp.c b/pp.c
index 4ce7867..60eaf28 100644
--- a/pp.c
+++ b/pp.c
@@ -2800,7 +2800,9 @@ PP(pp_int)
 	 else preferring IV has introduced a subtle behaviour change bug. OTOH
 	 relying on floating point to be accurate is a bug.  */
 
-      if (SvIOK(TOPs)) {
+      if (!SvOK(TOPs))
+        SETu(0);
+      else if (SvIOK(TOPs)) {
 	if (SvIsUV(TOPs)) {
 	    UV uv = TOPu;
 	    SETu(uv);
@@ -2834,7 +2836,9 @@ PP(pp_abs)
       /* This will cache the NV value if string isn't actually integer  */
       IV iv = TOPi;
 
-      if (SvIOK(TOPs)) {
+      if (!SvOK(TOPs))
+        SETu(0);
+      else if (SvIOK(TOPs)) {
 	/* IVX is precise  */
 	if (SvIsUV(TOPs)) {
 	  SETu(TOPu);	/* force it to be numeric only */
diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit
index 5bdfdb6..0c8a8d9 100644
--- a/t/lib/warnings/9uninit
+++ b/t/lib/warnings/9uninit
@@ -505,8 +505,6 @@ $v = int($g1);
 $v = abs($g2);
 EXPECT
 Use of uninitialized value $g1 in int at - line 5.
-Use of uninitialized value $g1 in int at - line 5.
-Use of uninitialized value $g2 in abs at - line 6.
 Use of uninitialized value $g2 in abs at - line 6.
 ########
 use warnings 'uninitialized';